|
VLink
2.0.0
A high-performance communication middleware
|
Sub-second-cached timestamp string generator used by the VLink logger hot path. More...
#include <atomic>#include <chrono>#include <cstdint>#include <mutex>#include <string_view>#include "./macros.h"Go to the source code of this file.
Classes | |
| class | vlink::CachedTimestamp |
| Mutable cached generator for short formatted timestamps. More... | |
Namespaces | |
| vlink | |
Sub-second-cached timestamp string generator used by the VLink logger hot path.
CachedTimestamp renders a wall-clock or UTC timestamp into a stable internal buffer and patches only the millisecond suffix when the seconds field has not advanced. This avoids the repeated snprintf / localtime_r round trip that dominates naive per-line logger output.
| Field | Width | Source |
|---|---|---|
| Month | 2 | %02d |
| Day | 2 | %02d |
| Hour | 2 | %02d |
| Minute | 2 | %02d |
| Second | 2 | %02d |
| Millisecond (in-place patch) | 3 | %03d, last three chars of buffer |
The default format "%02d-%02d @c %02d:%02d:%02d.%03d" produces 18 characters such as "03-18 14:30:01.042". The internal buffer is 32 bytes; longer formats are dropped.
vlink::Logger. Application code rarely needs to construct one directly; doing so is harmless and inexpensive.