Logger class for ostream or syslog.
Java style api for logging.
logger.info("Triggering compaction");
The output format is: (depending on level) DEBUG Y-m-d T,%03d [shard 0] - "your msg"
It is possible to rate-limit log messages, see logger::rate_limit.
#include <seastar/util/log.hh>
|
| logger (sstring name) |
|
| logger (logger &&x) |
|
bool | is_shard_zero () noexcept |
|
bool | is_enabled (log_level level) const noexcept |
|
template<typename... Args> |
void | log (log_level level, const char *fmt, Args &&... args) noexcept |
|
template<typename... Args> |
void | log (log_level level, rate_limit &rl, const char *fmt, Args &&... args) noexcept |
|
template<typename... Args> |
void | error (const char *fmt, Args &&... args) noexcept |
|
template<typename... Args> |
void | warn (const char *fmt, Args &&... args) noexcept |
|
template<typename... Args> |
void | info (const char *fmt, Args &&... args) noexcept |
|
template<typename... Args> |
void | info0 (const char *fmt, Args &&... args) noexcept |
|
template<typename... Args> |
void | debug (const char *fmt, Args &&... args) noexcept |
|
template<typename... Args> |
void | trace (const char *fmt, Args &&... args) noexcept |
|
const sstring & | name () const noexcept |
|
log_level | level () const noexcept |
|
void | set_level (log_level level) noexcept |
|
|
static void | set_ostream (std::ostream &out) noexcept |
| Set output stream, default is std::cerr.
|
|
static void | set_ostream_enabled (bool enabled) noexcept |
| Also output to ostream. default is true.
|
|
static void | set_stdout_enabled (bool enabled) noexcept |
| Also output to stdout. default is true.
|
|
static void | set_syslog_enabled (bool enabled) noexcept |
|
◆ debug()
template<typename... Args>
void seastar::logger::debug |
( |
const char * |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
|
inlinenoexcept |
Log with debug tag: DEBUG Y-m-d T,%03d [shard 0] - "your msg"
- Parameters
-
fmt | - {fmt} style format |
args | - args to print string |
◆ error()
template<typename... Args>
void seastar::logger::error |
( |
const char * |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
|
inlinenoexcept |
Log with error tag: ERROR Y-m-d T,%03d [shard 0] - "your msg"
- Parameters
-
fmt | - {fmt} style format |
args | - args to print string |
◆ info()
template<typename... Args>
void seastar::logger::info |
( |
const char * |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
|
inlinenoexcept |
Log with info tag: INFO Y-m-d T,%03d [shard 0] - "your msg"
- Parameters
-
fmt | - {fmt} style format |
args | - args to print string |
◆ info0()
template<typename... Args>
void seastar::logger::info0 |
( |
const char * |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
|
inlinenoexcept |
Log with info tag on shard zero only: INFO Y-m-d T,%03d [shard 0] - "your msg"
- Parameters
-
fmt | - {fmt} style format |
args | - args to print string |
◆ is_enabled()
bool seastar::logger::is_enabled |
( |
log_level |
level | ) |
const |
|
inlinenoexcept |
Test if desired log level is enabled
- Parameters
-
level | - enum level value (info|error...) |
- Returns
- true if the log level has been enabled.
◆ level()
- Returns
- current log level for this logger
◆ log() [1/2]
template<typename... Args>
void seastar::logger::log |
( |
log_level |
level, |
|
|
const char * |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
|
inlinenoexcept |
logs to desired level if enabled, otherwise we ignore the log line
- Parameters
-
fmt | - {fmt} style format |
args | - args to print string |
◆ log() [2/2]
template<typename... Args>
void seastar::logger::log |
( |
log_level |
level, |
|
|
rate_limit & |
rl, |
|
|
const char * |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
|
inlinenoexcept |
logs with a rate limit to desired level if enabled, otherwise we ignore the log line
If there were messages dropped due to rate-limiting the following snippet will be prepended to the first non-dropped log messages:
(rate limiting dropped $N similar messages)
Where $N is the number of messages dropped.
- Parameters
-
rl | - the rate_limit to apply to this log |
fmt | - {fmt} style format |
args | - args to print string |
◆ name()
const sstring& seastar::logger::name |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- name of the logger. Usually one logger per module
◆ set_level()
void seastar::logger::set_level |
( |
log_level |
level | ) |
|
|
inlinenoexcept |
◆ set_syslog_enabled()
static void seastar::logger::set_syslog_enabled |
( |
bool |
enabled | ) |
|
|
staticnoexcept |
Also output to syslog. default is false
NOTE: syslog() can block, which will stall the reactor thread. this should be rare (will have to fill the pipe buffer before syslogd can clear it) but can happen.
◆ trace()
template<typename... Args>
void seastar::logger::trace |
( |
const char * |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
|
inlinenoexcept |
Log with trace tag: TRACE Y-m-d T,%03d [shard 0] - "your msg"
- Parameters
-
fmt | - {fmt} style format |
args | - args to print string |
◆ warn()
template<typename... Args>
void seastar::logger::warn |
( |
const char * |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
|
inlinenoexcept |
Log with warning tag: WARN Y-m-d T,%03d [shard 0] - "your msg"
- Parameters
-
fmt | - {fmt} style format |
args | - args to print string |
The documentation for this class was generated from the following file: