Github   Telegram
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
components::Logging Class Referencefinal

Logging component More...

#include <userver/logging/component.hpp>

+ Inheritance diagram for components::Logging:
+ Collaboration diagram for components::Logging:

Public Member Functions

 Logging (const ComponentConfig &, const ComponentContext &)
 The component constructor.
 
logging::LoggerPtr GetLogger (const std::string &name)
 Returns a logger by its name. More...
 
logging::LoggerPtr GetLoggerOptional (const std::string &name)
 Returns a logger by its name. More...
 
void StartSocketLoggingDebug ()
 
void StopSocketLoggingDebug ()
 
void OnLogRotate ()
 Reopens log files after rotation.
 
void TryReopenFiles ()
 

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
 

Static Public Attributes

static constexpr std::string_view kName = "logging"
 The default name of this component. More...
 

Detailed Description

Logging component

Allows to configure the default logger and/or additional loggers for your needs.

Static options:

Name Description Default value
file_path path to the log file -
level log verbosity info
format log output format, either tskv or ltsv tskv
flush_level messages of this and higher levels get flushed to the file immediately warning
message_queue_size the size of internal message queue, must be a power of 2 65536
overflow_behavior message handling policy while the queue is full: discard drops messages, block waits until message gets into the queue discard
testsuite-capture if exists, setups additional TCP log sink for testing purposes {}

Logs output

You can specify logger output, in file_path option:

testsuite-capture options:

Name Description Default value
host testsuite hostname, e.g. localhost -
port testsuite port -

Static configuration example:

# yaml
fs-task-processor: fs-task-processor
loggers:
access:
file_path: $access_log_path
overflow_behavior: discard
format: raw
access-tskv:
file_path: $access_tskv_log_path
overflow_behavior: discard
format: raw
default:
file_path: $default_log_path
level: $log_level
level#fallback: debug
overflow_behavior: discard
tracer:
file_path: '@stdout'
overflow_behavior: discard

default section configures the default logger for LOG_*.

Definition at line 68 of file component.hpp.

Member Function Documentation

◆ GetLogger()

logging::LoggerPtr components::Logging::GetLogger ( const std::string &  name)

Returns a logger by its name.

Parameters
nameName of the logger
Returns
Pointer to the Logger instance
Exceptions
std::runtime_errorif logger with this name is not registered

◆ GetLoggerOptional()

logging::LoggerPtr components::Logging::GetLoggerOptional ( const std::string &  name)

Returns a logger by its name.

Parameters
nameName of the logger
Returns
Pointer to the Logger instance, or nullptr if not registered

Member Data Documentation

◆ kName

constexpr std::string_view components::Logging::kName = "logging"
staticconstexpr

The default name of this component.

Definition at line 71 of file component.hpp.


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