VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::CachedTimestamp类 参考final

Cached, thread-safe formatted timestamp generator. 更多...

#include <cached_timestamp.h>

vlink::CachedTimestamp 的协作图:

Public 成员函数

 CachedTimestamp ()
 Constructs a CachedTimestamp with an empty internal cache.
 ~CachedTimestamp ()
 Destructor.
std::string_view get (const char *format="%02d-%02d %02d:%02d:%02d.%03d", bool use_utc=false)
 Returns a std::string_view of the current formatted timestamp.

详细描述

Cached, thread-safe formatted timestamp generator.

Reformats only the seconds portion of the timestamp once per second, patching the milliseconds in-place for all other calls. Used internally by the Logger to stamp each log line.

构造及析构函数说明

◆ CachedTimestamp()

vlink::CachedTimestamp::CachedTimestamp ( )

Constructs a CachedTimestamp with an empty internal cache.

The cache is populated on the first call to get().

◆ ~CachedTimestamp()

vlink::CachedTimestamp::~CachedTimestamp ( )

Destructor.

成员函数说明

◆ get()

std::string_view vlink::CachedTimestamp::get ( const char * format = "%02d-%02d %02d:%02d:%02d.%03d",
bool use_utc = false )
nodiscard

Returns a std::string_view of the current formatted timestamp.

The view points into the internal 32-byte buffer. It is valid until the next call to get() from any thread that shares this instance. Copy the string if a persistent value is needed.

The default format produces strings of the form "MM-DD HH:MM:SS.mmm".

参数
formatA snprintf-compatible format string. Must include exactly one %03d placeholder for milliseconds. The resulting string must fit within 31 characters. Default: "%02d-%02d %02d:%02d:%02d.%03d"
use_utcIf true, formats in UTC; if false (default), in local time.
返回
A std::string_view into the internal buffer with the current timestamp.
注解
The returned view is invalidated on the next call from any thread that holds a reference to this CachedTimestamp instance.

该类的文档由以下文件生成: