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");

The output format is: (depending on level) DEBUG Y-m-d T,%03d [shard 0] - "your msg"

#include <seastar/util/log.hh>

Classes

class  lambda_log_writer
 
class  log_writer
 

Public Member Functions

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

Member Function Documentation

◆ 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()

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

◆ log()

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

◆ 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_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:
seastar::logger
Logger class for ostream or syslog.
Definition: log.hh:80