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 
6 #pragma once
7 
8 #include <stdarg.h>
9 #include <stdio.h>
10 
11 #include "rocksdb/env.h"
12 
13 namespace ROCKSDB_NAMESPACE {
14 
15 // Prints logs to stderr for faster debugging
16 class StderrLogger : public Logger {
17  public:
18   explicit StderrLogger(const InfoLogLevel log_level = InfoLogLevel::INFO_LEVEL)
Logger(log_level)19       : Logger(log_level) {}
20 
21   // Brings overloaded Logv()s into scope so they're not hidden when we override
22   // a subset of them.
23   using Logger::Logv;
24 
Logv(const char * format,va_list ap)25   virtual void Logv(const char* format, va_list ap) override {
26     vfprintf(stderr, format, ap);
27     fprintf(stderr, "\n");
28   }
29 };
30 
31 }  // namespace ROCKSDB_NAMESPACE
32