/Users/deen/code/yugabyte-db/src/yb/rocksutil/yb_rocksdb_logger.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_ROCKSUTIL_YB_ROCKSDB_LOGGER_H |
15 | | #define YB_ROCKSUTIL_YB_ROCKSDB_LOGGER_H |
16 | | |
17 | | #include <string> |
18 | | #include "yb/rocksdb/env.h" |
19 | | |
20 | | namespace yb { |
21 | | |
22 | | class YBRocksDBLogger : public rocksdb::Logger { |
23 | | public: |
24 | 673k | explicit YBRocksDBLogger(const std::string& prefix) : prefix_(prefix) {} |
25 | | |
26 | 633k | ~YBRocksDBLogger() {} |
27 | | |
28 | | // Write an entry to the log file with the specified format. |
29 | 0 | void Logv(const char* format, va_list ap) override { |
30 | 0 | Logv(rocksdb::INFO_LEVEL, format, ap); |
31 | 0 | } |
32 | | |
33 | | void Logv(const rocksdb::InfoLogLevel log_level, const char* format, va_list ap) override; |
34 | | |
35 | | // Write an entry to the log file with the specified log level and format. Any log with level |
36 | | // under the internal log level of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be |
37 | | // printed. |
38 | | void LogvWithContext(const char* file, |
39 | | const int line, |
40 | | const rocksdb::InfoLogLevel log_level, |
41 | | const char* format, |
42 | | va_list ap) override; |
43 | | |
44 | | // Convert from glog level to rocksdb log level. |
45 | | static rocksdb::InfoLogLevel ConvertToRocksDBLogLevel(const int glog_level); |
46 | | |
47 | 451k | const std::string& Prefix() const override { |
48 | 451k | return prefix_; |
49 | 451k | } |
50 | | |
51 | | private: |
52 | | // Convert from rocksdb log level to glog level. |
53 | | static int ConvertToGLogLevel(const rocksdb::InfoLogLevel rocksdb_log_level); |
54 | | |
55 | | const std::string prefix_; |
56 | | }; |
57 | | |
58 | | } // namespace yb |
59 | | |
60 | | #endif // YB_ROCKSUTIL_YB_ROCKSDB_LOGGER_H |