LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
logit::detail Namespace Reference

Classes

class  CompressionWorker
 Background worker performing asynchronous compression. More...
 
class  MdbxByteReader
 
class  MdbxByteWriter
 
class  MdbxReadException
 
class  MpscRingAny
 Bounded MPSC ring buffer with arbitrary capacity (C++11). More...
 
class  ScopeTimer
 
class  SingleThreadExecutor
 Per-instance single-thread executor for isolated async logging. More...
 
class  TaskExecutor
 Thread-safe task executor backed by a dedicated worker thread. More...
 

Enumerations

enum class  QueuePolicy { DropNewest , DropOldest , Block }
 Queue overflow handling policy used by TaskExecutor and SingleThreadExecutor. More...
 

Functions

bool compress_string_gzip (const std::string &input, std::string &output, int level)
 Compress a string with gzip.
 
bool decompress_string_gzip (const std::string &input, std::string &output)
 Decompress gzip-compressed bytes.
 
bool compress_string_zstd (const std::string &input, std::string &output, int level)
 Compress a string with zstd.
 
bool decompress_string_zstd (const std::string &input, std::string &output)
 Decompress zstd-compressed bytes.
 
bool compress_file (CompressType type, const std::string &src, int level, const std::string &external_cmd)
 Compress a file using the specified compression type.
 
int clamp_level (int v, int lo, int hi)
 Clamp value to inclusive range.
 
bool compress_file_gzip (const std::string &src, const std::string &dst_tmp, int level)
 Compress file using gzip.
 
bool compress_file_zstd (const std::string &src, const std::string &dst_tmp, int level)
 Compress file using Zstandard.
 
bool compress_file_external (const std::string &src, const std::string &cmd_tpl, int level)
 Compress file using external command.
 
void mdbx_write_record_key_be (std::string &key, uint64_t value, size_t offset)
 
void mdbx_write_record_sequence_be (std::string &key, uint32_t value, size_t offset)
 
std::string make_mdbx_record_key (int64_t timestamp_ms, uint32_t sequence)
 
uint64_t current_process_id ()
 
template<typename T >
std::string to_string_any (const T &v)
 Convert value to string via stream insertion.
 
std::pair< std::string, std::string > make_tag (std::string key, std::string value)
 Create tag from string key and value.
 
template<typename V >
std::pair< std::string, std::string > make_tag (const char *key, const V &v)
 Create tag from C-string key and arbitrary value.
 
std::string format_tags (std::initializer_list< std::pair< std::string, std::string > > tags)
 Format tag list into a single string.
 
template<typename T >
std::string make_section (const T &name)
 Format a raw section name as [name].
 

Enumeration Type Documentation

◆ QueuePolicy

enum class logit::detail::QueuePolicy
strong

Queue overflow handling policy used by TaskExecutor and SingleThreadExecutor.

Enumerator
DropNewest 

Reject the incoming task when the queue is full.

DropOldest 

Drop-oldest policy; MPSC mode rejects the incoming task to preserve the ordering of already accepted work.

Block 

Producers wait until capacity is available.

Definition at line 8 of file QueuePolicy.hpp.

Function Documentation

◆ clamp_level()

int logit::detail::clamp_level ( int v,
int lo,
int hi )
inline

Clamp value to inclusive range.

Parameters
vInput value.
loLower bound.
hiUpper bound.
Returns
Clamped value.

Definition at line 80 of file CompressionWorker.hpp.

◆ compress_file()

bool logit::detail::compress_file ( CompressType type,
const std::string & src,
int level,
const std::string & external_cmd )
inline

Compress a file using the specified compression type.

Parameters
typeCompression algorithm to use.
srcPath to the source file.
levelCompression level.
external_cmdCommand template for CompressType::EXTERNAL_CMD.
Returns
true on success.

Definition at line 184 of file CompressionWorker.hpp.

◆ compress_file_external()

bool logit::detail::compress_file_external ( const std::string & src,
const std::string & cmd_tpl,
int level )
inline

Compress file using external command.

Parameters
srcSource path.
cmd_tplCommand template containing {file} and {level}.
levelCompression level.
Returns
true on success.

Definition at line 172 of file CompressionWorker.hpp.

◆ compress_file_gzip()

bool logit::detail::compress_file_gzip ( const std::string & src,
const std::string & dst_tmp,
int level )
inline

Compress file using gzip.

Parameters
srcSource path.
dst_tmpTemporary output path.
levelCompression level.
Returns
true on success.

Definition at line 91 of file CompressionWorker.hpp.

◆ compress_file_zstd()

bool logit::detail::compress_file_zstd ( const std::string & src,
const std::string & dst_tmp,
int level )
inline

Compress file using Zstandard.

Parameters
srcSource path.
dst_tmpTemporary output path.
levelCompression level.
Returns
true on success.

Definition at line 124 of file CompressionWorker.hpp.

◆ compress_string_gzip()

bool logit::detail::compress_string_gzip ( const std::string & input,
std::string & output,
int level )
inline

Compress a string with gzip.

Parameters
inputUncompressed data.
[out]outputCompressed result (valid only on success).
levelCompression level 1-9.
Returns
true on success, false if zlib is unavailable or compression fails.
Note
Callers must check the return value and handle fallback explicitly.

Definition at line 28 of file CompressionUtils.hpp.

◆ compress_string_zstd()

bool logit::detail::compress_string_zstd ( const std::string & input,
std::string & output,
int level )
inline

Compress a string with zstd.

Parameters
inputUncompressed data.
[out]outputCompressed result (valid only on success).
levelCompression level 1-19.
Returns
true on success, false if zstd is unavailable or compression fails.
Note
Callers must check the return value and handle fallback explicitly.

Definition at line 131 of file CompressionUtils.hpp.

◆ current_process_id()

uint64_t logit::detail::current_process_id ( )
inline

Definition at line 19 of file MdbxProcessId.hpp.

◆ decompress_string_gzip()

bool logit::detail::decompress_string_gzip ( const std::string & input,
std::string & output )
inline

Decompress gzip-compressed bytes.

Parameters
inputCompressed data.
[out]outputDecompressed result (valid only on success).
Returns
true on success, false if zlib is unavailable or decompression fails.

Definition at line 80 of file CompressionUtils.hpp.

◆ decompress_string_zstd()

bool logit::detail::decompress_string_zstd ( const std::string & input,
std::string & output )
inline

Decompress zstd-compressed bytes.

Parameters
inputCompressed data.
[out]outputDecompressed result (valid only on success).
Returns
true on success, false if zstd is unavailable or decompression fails.

Definition at line 161 of file CompressionUtils.hpp.

◆ format_tags()

std::string logit::detail::format_tags ( std::initializer_list< std::pair< std::string, std::string > > tags)
inline

Format tag list into a single string.

Parameters
tagsTags to format.
Returns
Serialized tag string.

Definition at line 47 of file tag_utils.hpp.

◆ make_mdbx_record_key()

std::string logit::detail::make_mdbx_record_key ( int64_t timestamp_ms,
uint32_t sequence )
inline

Definition at line 27 of file MdbxKeyUtils.hpp.

◆ make_section()

template<typename T >
std::string logit::detail::make_section ( const T & name)
inline

Format a raw section name as [name].

Template Parameters
TSection name type supporting operator<<.
Parameters
nameSection name.
Returns
Section header text.

Definition at line 86 of file tag_utils.hpp.

◆ make_tag() [1/2]

template<typename V >
std::pair< std::string, std::string > logit::detail::make_tag ( const char * key,
const V & v )
inline

Create tag from C-string key and arbitrary value.

Template Parameters
VValue type convertible to string.
Parameters
keyTag name.
vTag value.
Returns
Key/value pair.

Definition at line 40 of file tag_utils.hpp.

◆ make_tag() [2/2]

std::pair< std::string, std::string > logit::detail::make_tag ( std::string key,
std::string value )
inline

Create tag from string key and value.

Parameters
keyTag name.
valueTag value.
Returns
Key/value pair.

Definition at line 30 of file tag_utils.hpp.

◆ mdbx_write_record_key_be()

void logit::detail::mdbx_write_record_key_be ( std::string & key,
uint64_t value,
size_t offset )
inline

Definition at line 15 of file MdbxKeyUtils.hpp.

◆ mdbx_write_record_sequence_be()

void logit::detail::mdbx_write_record_sequence_be ( std::string & key,
uint32_t value,
size_t offset )
inline

Definition at line 21 of file MdbxKeyUtils.hpp.

◆ to_string_any()

template<typename T >
std::string logit::detail::to_string_any ( const T & v)
inline

Convert value to string via stream insertion.

Template Parameters
TValue type supporting operator<<.
Parameters
vValue to convert.
Returns
String representation.

Definition at line 20 of file tag_utils.hpp.