1 | // Copyright (c) 2011-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 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. |
7 | // Use of this source code is governed by a BSD-style license that can be |
8 | // found in the LICENSE file. See the AUTHORS file for names of contributors. |
9 | // |
10 | // Must not be included from any .h files to avoid polluting the namespace |
11 | // with macros. |
12 | |
13 | #pragma once |
14 | #include "port/port.h" |
15 | |
16 | // Helper macros that include information about file name and line number |
17 | #define STRINGIFY(x) #x |
18 | #define TOSTRING(x) STRINGIFY(x) |
19 | #define PREPEND_FILE_LINE(FMT) ("[" __FILE__ ":" TOSTRING(__LINE__) "] " FMT) |
20 | |
21 | // Don't inclide file/line info in HEADER level |
22 | #define (LGR, FMT, ...) \ |
23 | rocksdb::Log(InfoLogLevel::HEADER_LEVEL, LGR, FMT, ##__VA_ARGS__) |
24 | |
25 | #define ROCKS_LOG_DEBUG(LGR, FMT, ...) \ |
26 | rocksdb::Log(InfoLogLevel::DEBUG_LEVEL, LGR, PREPEND_FILE_LINE(FMT), \ |
27 | ##__VA_ARGS__) |
28 | |
29 | #define ROCKS_LOG_INFO(LGR, FMT, ...) \ |
30 | rocksdb::Log(InfoLogLevel::INFO_LEVEL, LGR, PREPEND_FILE_LINE(FMT), \ |
31 | ##__VA_ARGS__) |
32 | |
33 | #define ROCKS_LOG_WARN(LGR, FMT, ...) \ |
34 | rocksdb::Log(InfoLogLevel::WARN_LEVEL, LGR, PREPEND_FILE_LINE(FMT), \ |
35 | ##__VA_ARGS__) |
36 | |
37 | #define ROCKS_LOG_ERROR(LGR, FMT, ...) \ |
38 | rocksdb::Log(InfoLogLevel::ERROR_LEVEL, LGR, PREPEND_FILE_LINE(FMT), \ |
39 | ##__VA_ARGS__) |
40 | |
41 | #define ROCKS_LOG_FATAL(LGR, FMT, ...) \ |
42 | rocksdb::Log(InfoLogLevel::FATAL_LEVEL, LGR, PREPEND_FILE_LINE(FMT), \ |
43 | ##__VA_ARGS__) |
44 | |
45 | #define ROCKS_LOG_BUFFER(LOG_BUF, FMT, ...) \ |
46 | rocksdb::LogToBuffer(LOG_BUF, PREPEND_FILE_LINE(FMT), ##__VA_ARGS__) |
47 | |
48 | #define ROCKS_LOG_BUFFER_MAX_SZ(LOG_BUF, MAX_LOG_SIZE, FMT, ...) \ |
49 | rocksdb::LogToBuffer(LOG_BUF, MAX_LOG_SIZE, PREPEND_FILE_LINE(FMT), \ |
50 | ##__VA_ARGS__) |
51 | |