stderr_logger.h 870 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #pragma once
  6. #include <stdarg.h>
  7. #include <stdio.h>
  8. #include "rocksdb/env.h"
  9. namespace ROCKSDB_NAMESPACE {
  10. // Prints logs to stderr for faster debugging
  11. class StderrLogger : public Logger {
  12. public:
  13. explicit StderrLogger(const InfoLogLevel log_level = InfoLogLevel::INFO_LEVEL)
  14. : Logger(log_level) {}
  15. // Brings overloaded Logv()s into scope so they're not hidden when we override
  16. // a subset of them.
  17. using Logger::Logv;
  18. virtual void Logv(const char* format, va_list ap) override {
  19. vfprintf(stderr, format, ap);
  20. fprintf(stderr, "\n");
  21. }
  22. };
  23. } // namespace ROCKSDB_NAMESPACE