numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::logging::sinks::log_sink Class Reference

Class of log sinks. More...

#include <num_collect/logging/sinks/log_sink.h>

+ Collaboration diagram for num_collect::logging::sinks::log_sink:

Public Types

using finalizer_type = void (*)(void* ) noexcept
 Type of functions to finalize the lgo sink.
 
using write_function_type
 Type of functions to write logs.
 

Public Member Functions

 log_sink (const log_sink &obj) noexcept
 Copy constructor.
 
 log_sink (log_sink &&obj) noexcept
 Move constructor.
 
 log_sink (void *user_data, write_function_type write_function, finalizer_type finalizer)
 Constructor.
 
 ~log_sink ()
 Destructor.
 
auto operator= (const log_sink &obj) noexcept -> log_sink &
 Copy assignment operator.
 
auto operator= (log_sink &&obj) noexcept -> log_sink &
 Move assignment operator.
 
void write (time_stamp time, std::string_view tag, log_level level, util::source_info_view source, std::string_view body) const noexcept
 Write a log.
 

Private Attributes

finalizer_type finalizer_
 Function to finalize the log sink.
 
reference_count * reference_count_
 Reference count.
 
void * user_data_
 User data.
 
write_function_type write_function_
 Function to write logs.
 

Detailed Description

Class of log sinks.

Note
This class holds pointers passed to the constructor and their reference count as in std::shared_ptr. A finalizer is called when the reference count comes to zero.

Definition at line 39 of file log_sink.h.

Member Typedef Documentation

◆ finalizer_type

using num_collect::logging::sinks::log_sink::finalizer_type = void (*)(void* ) noexcept

Type of functions to finalize the lgo sink.

The argument is the user data given in the constructor.

Definition at line 58 of file log_sink.h.

◆ write_function_type

Initial value:
void (*)(void* ,
time_stamp , std::string_view , log_level ,
util::source_info_view , std::string_view ) noexcept
log_level
Enumeration of log levels.
Definition log_level.h:47

Type of functions to write logs.

The first argument is the user data given in the constructor. The other arguments are the same as the arguments of write().

Note
This function is assumed to be thread-safe.

Definition at line 49 of file log_sink.h.

Constructor & Destructor Documentation

◆ log_sink() [1/3]

num_collect::logging::sinks::log_sink::log_sink ( void * user_data,
write_function_type write_function,
finalizer_type finalizer )

Constructor.

Parameters
[in]user_dataUser data.
[in]write_functionFunction to write logs.
[in]finalizerFunction to finalize the log sink.

◆ log_sink() [2/3]

num_collect::logging::sinks::log_sink::log_sink ( const log_sink & obj)
noexcept

Copy constructor.

Parameters
[in]objObject to copy from.

◆ log_sink() [3/3]

num_collect::logging::sinks::log_sink::log_sink ( log_sink && obj)
noexcept

Move constructor.

Parameters
[in]objObject to move from.

Member Function Documentation

◆ operator=() [1/2]

auto num_collect::logging::sinks::log_sink::operator= ( const log_sink & obj) -> log_sink &
noexcept

Copy assignment operator.

Parameters
[in]objObject to copy from.
Returns
This object.

◆ operator=() [2/2]

auto num_collect::logging::sinks::log_sink::operator= ( log_sink && obj) -> log_sink &
noexcept

Move assignment operator.

Parameters
[in]objObject to move from.
Returns
This object.

◆ write()

void num_collect::logging::sinks::log_sink::write ( time_stamp time,
std::string_view tag,
log_level level,
util::source_info_view source,
std::string_view body ) const
noexcept

Write a log.

Parameters
[in]timeTime.
[in]tagTag.
[in]levelLog level.
[in]sourceInformation of the source code.
[in]bodyLog body.
Note
This function can be called from multiple threads.

Member Data Documentation

◆ finalizer_

finalizer_type num_collect::logging::sinks::log_sink::finalizer_
private

Function to finalize the log sink.

Definition at line 130 of file log_sink.h.

◆ reference_count_

reference_count* num_collect::logging::sinks::log_sink::reference_count_
private

Reference count.

Definition at line 133 of file log_sink.h.

◆ user_data_

void* num_collect::logging::sinks::log_sink::user_data_
private

User data.

Definition at line 124 of file log_sink.h.

◆ write_function_

write_function_type num_collect::logging::sinks::log_sink::write_function_
private

Function to write logs.

Definition at line 127 of file log_sink.h.


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