Seastar
High performance C++ framework for concurrent servers
Classes | Public Member Functions | Static Public Member Functions | List of all members
seastar::logger Class Reference

Detailed Description

Logger class for ostream or syslog.

Java style api for logging.

static seastar::logger logger("lsa-api");
logger.info("Triggering compaction");
Logger class for ostream or syslog.
Definition: log.hh:90
void info(format_info fmt, Args &&... args) noexcept
Definition: log.hh:355

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>

Classes

class  lambda_log_writer
 
class  log_writer
 

Public Member Functions

template<typename... Args>
void error (format_info fmt, Args &&... args) noexcept
 
template<typename... Args>
void warn (format_info fmt, Args &&... args) noexcept
 
template<typename... Args>
void info (format_info fmt, Args &&... args) noexcept
 
template<typename... Args>
void info0 (format_info fmt, Args &&... args) noexcept
 
template<typename... Args>
void debug (format_info fmt, Args &&... args) noexcept
 
template<typename... Args>
void trace (format_info fmt, Args &&... args) noexcept
 
const sstring & name () const noexcept
 
log_level level () const noexcept
 
void set_level (log_level level) noexcept
 

Static Public Member Functions

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
 
static void set_shard_field_width (unsigned width) noexcept
 
static void set_with_color (bool enabled) noexcept
 

Member Function Documentation

◆ debug()

template<typename... Args>
void seastar::logger::debug ( format_info  fmt,
Args &&...  args 
)
inlinenoexcept

Log with debug tag: DEBUG Y-m-d T,%03d [shard 0] - "your msg"

Parameters
fmt- {fmt} style format string (implictly converted to struct logger::format_info) or a logger::format_info passed down the call chain.
args- args to print string

◆ error()

template<typename... Args>
void seastar::logger::error ( format_info  fmt,
Args &&...  args 
)
inlinenoexcept

Log with error tag: ERROR Y-m-d T,%03d [shard 0] - "your msg"

Parameters
fmt- {fmt} style format string (implictly converted to struct logger::format_info) or a logger::format_info passed down the call chain.
args- args to print string

◆ info()

template<typename... Args>
void seastar::logger::info ( format_info  fmt,
Args &&...  args 
)
inlinenoexcept

Log with info tag: INFO Y-m-d T,%03d [shard 0] - "your msg"

Parameters
fmt- {fmt} style format string (implictly converted to struct logger::format_info) or a logger::format_info passed down the call chain.
args- args to print string

◆ info0()

template<typename... Args>
void seastar::logger::info0 ( format_info  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 string (implictly converted to struct logger::format_info) or a logger::format_info passed down the call chain.
args- args to print string

◆ level()

log_level seastar::logger::level ( ) const
inlinenoexcept
Returns
current log level for this logger

◆ 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
Parameters
level- set the log level

◆ set_shard_field_width()

static void seastar::logger::set_shard_field_width ( unsigned  width)
staticnoexcept

Set the width of shard id field in log messages

this_shard_id() is printed as a part of the prefix in logging messages, like "[shard 42]", where 42 is the decimal number of the current shard id printed with a minimal width.

Parameters
widththe minimal width of the shard id field

◆ 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.

◆ set_with_color()

static void seastar::logger::set_with_color ( bool  enabled)
staticnoexcept

enable/disable the colored tag in ostream

Note
this is a noop if fmtlib's version is less than 6.0

◆ trace()

template<typename... Args>
void seastar::logger::trace ( format_info  fmt,
Args &&...  args 
)
inlinenoexcept

Log with trace tag: TRACE Y-m-d T,%03d [shard 0] - "your msg"

Parameters
fmt- {fmt} style format string (implictly converted to struct logger::format_info) or a logger::format_info passed down the call chain.
args- args to print string

◆ warn()

template<typename... Args>
void seastar::logger::warn ( format_info  fmt,
Args &&...  args 
)
inlinenoexcept

Log with warning tag: WARN Y-m-d T,%03d [shard 0] - "your msg"

Parameters
fmt- {fmt} style format string (implictly converted to struct logger::format_info) or a logger::format_info passed down the call chain.
args- args to print string

The documentation for this class was generated from the following file: