cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
msgpack_rpc::logging::Logger Class Reference

Class to write logs. More...

#include <msgpack_rpc/logging/logger.h>

Collaboration diagram for msgpack_rpc::logging::Logger:

Public Member Functions

 Logger (std::shared_ptr< ILogSink > sink, LogLevel output_log_level)
 Constructor.
LogLevel output_log_level () const noexcept
 Get the log level to write logs.
template<typename Body>
void write (SourceLocationView location, LogLevel level, Body &&body)
 Write a log.
template<typename... Args>
void write (SourceLocationView location, LogLevel level, fmt::format_string< Args... > format, Args &&... args)
 Write a log with formatting.

Static Public Member Functions

static std::shared_ptr< Loggercreate (const config::LoggingConfig &config=config::LoggingConfig())
 Create a logger.
static std::shared_ptr< Loggercreate (std::shared_ptr< ILogSink > sink, LogLevel output_log_level=LogLevel::INFO)
 Create a logger.

Private Attributes

LogLevel output_log_level_
 Log level.
std::shared_ptr< ILogSinksink_
 Log sink.

Detailed Description

Class to write logs.

Note
This class is assumed to be used in the following logging macros.

Definition at line 54 of file logger.h.

Constructor & Destructor Documentation

◆ Logger()

msgpack_rpc::logging::Logger::Logger ( std::shared_ptr< ILogSink > sink,
LogLevel output_log_level )
inline

Constructor.

Parameters
[in]sinkLog sink.
[in]output_log_levelLog level to write logs.

Definition at line 87 of file logger.h.

Member Function Documentation

◆ create() [1/2]

std::shared_ptr< Logger > msgpack_rpc::logging::Logger::create ( const config::LoggingConfig & config = config::LoggingConfig())
inlinestaticnodiscard

Create a logger.

Parameters
[in]configConfiguration of logging.
Returns
Logger.
Examples
more_client.cpp, and more_server.cpp.

Definition at line 62 of file logger.h.

◆ create() [2/2]

std::shared_ptr< Logger > msgpack_rpc::logging::Logger::create ( std::shared_ptr< ILogSink > sink,
LogLevel output_log_level = LogLevel::INFO )
inlinestaticnodiscard

Create a logger.

Parameters
[in]sinkLog sink.
[in]output_log_levelLog level to write logs.
Returns
Logger.

Definition at line 75 of file logger.h.

◆ output_log_level()

LogLevel msgpack_rpc::logging::Logger::output_log_level ( ) const
inlinenodiscardnoexcept

Get the log level to write logs.

Returns
Log level.

Definition at line 134 of file logger.h.

◆ write() [1/2]

template<typename Body>
void msgpack_rpc::logging::Logger::write ( SourceLocationView location,
LogLevel level,
Body && body )
inline

Write a log.

Template Parameters
BodyType of the body of the log. (Must be convertible to std::string_view.)
Parameters
[in]locationLocation in source codes.
[in]levelLog level.
[in]bodyBody of the log.

Definition at line 100 of file logger.h.

◆ write() [2/2]

template<typename... Args>
void msgpack_rpc::logging::Logger::write ( SourceLocationView location,
LogLevel level,
fmt::format_string< Args... > format,
Args &&... args )
inline

Write a log with formatting.

Template Parameters
ArgsType of arguments of the format of the body.
Parameters
[in]locationLocation in source codes.
[in]levelLog level.
[in]formatFormat of the body.
[in]argsArguments of the format of the body.

Definition at line 118 of file logger.h.

Member Data Documentation

◆ output_log_level_

LogLevel msgpack_rpc::logging::Logger::output_log_level_
private

Log level.

Definition at line 143 of file logger.h.

◆ sink_

std::shared_ptr<ILogSink> msgpack_rpc::logging::Logger::sink_
private

Log sink.

Definition at line 140 of file logger.h.


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