|
Fray Engine
|
Classes | |
| class | EngineLogSink |
| Captures Engine logs before managers exist and forwards them once attached. Construct before startup logging. The attachment must be destroyed before its managers. More... | |
| class | ProjectScope |
| Temporarily tag log lines on the calling thread, then restore its previous tag. Construct and destroy the scope on the same thread. More... | |
| class | SinkSuppression |
| Keeps the calling thread's printed lines out of the sink while it lives, then restores the previous setting. Used for lines that are recorded elsewhere under their own identity. Construct and destroy on the same thread. More... | |
| class | ConsoleSuppression |
| Keeps lines in the persistent log but out of the Console for this thread's scope. More... | |
Typedefs | |
| using | TimestampBuffer = F_char[TIMESTAMP_SIZE] |
| Timestamp buffer type. | |
| using | dateBuffer = F_char[DATE_SIZE] |
| Date buffer type. | |
| using | timeBuffer = F_char[TIME_SIZE] |
| Time buffer type. | |
| using | Sink = std::function<void(const F_char *PID, const F_char *level, F_long thread, const std::string &project, const F_char *message, bool consoleVisible)> |
| Receives each printed line synchronously on the logging thread; it must not log. The sink runs without the output or sink mutex held; concurrent calls may overlap. | |
Functions | |
| F_void | generateTimestamp (F_char *timestamp, std::chrono::system_clock::time_point now=std::chrono::system_clock::now()) |
| Write "[HH:MM:SS:mmm] [YY.MM.DD]" into buffer. | |
| F_void | getDate (F_char *date) |
| Write "YY.MM.DD" into buffer. | |
| F_void | getTime (F_char *time, std::chrono::system_clock::time_point now=std::chrono::system_clock::now()) |
| Write "HH:MM:SS.mmm" into buffer. | |
| F_long | threadId () |
| Small sequential id for the calling thread, assigned on its first call (the first caller is 0). | |
| std::mutex & | sinkMutex () |
| Return the mutex protecting access to the shared sink slot. | |
| std::shared_ptr< Sink > & | sinkSlot () |
| Return the shared sink slot; callers must hold sinkMutex when accessing it. | |
| F_void | setSink (Sink sink) |
| Replace the sink; an empty function removes it. Locks sinkMutex; an in-flight logging call may still invoke the previous sink. | |
| std::string & | threadProject () |
| Return the calling thread's project tag; an empty tag denotes the application. | |
| bool & | sinkSuppressed () |
| Whether the calling thread's printed lines skip the sink, so they reach stdout only. | |
| bool & | consoleVisible () |
| Whether the calling thread's log entries may be shown in the Console. | |
| F_void | printf (const F_char *PID, const F_char *PIDColor, const F_char *level, const F_char *levelColor, const F_char *message) |
| Print a formatted log line with PID, level and colors. Serializes and flushes stdout, then invokes a snapshot of the sink on the calling thread without holding either mutex. The sink must not log and may run concurrently. | |
| F_void | vprintf_helper (const F_char *PID, const F_char *PIDColor, const F_char *level, const F_char *levelColor, const F_char *fmt, va_list args) |
| Format up to 1023 message bytes and delegate to printf(). | |
| F_void | electronInfo (const F_char *fmt,...) |
| Log info for Electron. | |
| F_void | electronWarn (const F_char *fmt,...) |
| Log warning for Electron. | |
| F_void | electronError (const F_char *fmt,...) |
| Log error for Electron. | |
| F_void | electronFatal (const F_char *fmt,...) |
| Log fatal for Electron. | |
| F_void | engineInfo (const F_char *fmt,...) |
| Log info for Engine. | |
| F_void | engineSession (const std::string &name) |
| Marks the start of a log session under the calling thread's project tag. The Engine records it as a session row, which the Console shows as a divider before the session's entries. | |
| F_void | engineInfo (const std::string &message) |
| Print an Engine info line without interpreting the message as a format string. | |
| F_void | engineWarn (const F_char *fmt,...) |
| Log warning for Engine. | |
| F_void | engineError (const F_char *fmt,...) |
| Log error for Engine. | |
| F_void | engineFatal (const F_char *fmt,...) |
| Log fatal for Engine. | |
Variables | |
| constexpr const F_char * | ANSI_RESET = "\033[0m" |
| ANSI reset code. | |
| constexpr const F_char * | ANSI_BOLD = "\033[1m" |
| ANSI bold. | |
| constexpr const F_char * | ANSI_UNDERLINE = "\033[4m" |
| ANSI underline. | |
| constexpr const F_char * | ANSI_BLINK = "\033[5m" |
| ANSI blink. | |
| constexpr const F_char * | ANSI_INVERSE = "\033[7m" |
| ANSI inverse. | |
| constexpr const F_char * | ANSI_FG_BLACK = "\033[30m" |
| ANSI FG black. | |
| constexpr const F_char * | ANSI_FG_RED = "\033[31m" |
| ANSI FG red. | |
| constexpr const F_char * | ANSI_FG_GREEN = "\033[32m" |
| ANSI FG green. | |
| constexpr const F_char * | ANSI_FG_YELLOW = "\033[33m" |
| ANSI FG yellow. | |
| constexpr const F_char * | ANSI_FG_BLUE = "\033[34m" |
| ANSI FG blue. | |
| constexpr const F_char * | ANSI_FG_MAGENTA = "\033[35m" |
| ANSI FG magenta. | |
| constexpr const F_char * | ANSI_FG_CYAN = "\033[36m" |
| ANSI FG cyan. | |
| constexpr const F_char * | ANSI_FG_WHITE = "\033[37m" |
| ANSI FG white. | |
| constexpr const F_char * | ANSI_FG_ORANGE = "\x1b[38;5;208m" |
| ANSI FG orange (256-color). | |
| constexpr const F_char * | ANSI_BG_BLACK = "\033[40m" |
| ANSI BG black. | |
| constexpr const F_char * | ANSI_BG_RED = "\033[41m" |
| ANSI BG red. | |
| constexpr const F_char * | ANSI_BG_GREEN = "\033[42m" |
| ANSI BG green. | |
| constexpr const F_char * | ANSI_BG_YELLOW = "\033[43m" |
| ANSI BG yellow. | |
| constexpr const F_char * | ANSI_BG_BLUE = "\033[44m" |
| ANSI BG blue. | |
| constexpr const F_char * | ANSI_BG_MAGENTA = "\033[45m" |
| ANSI BG magenta. | |
| constexpr const F_char * | ANSI_BG_CYAN = "\033[46m" |
| ANSI BG cyan. | |
| constexpr const F_char * | ANSI_BG_WHITE = "\033[47m" |
| ANSI BG white. | |
| constexpr const F_char * | ANSI_BG_ORANGE = "\033[48;5;208m" |
| ANSI BG orange (256-color). | |
| constexpr F_long | TIMESTAMP_SIZE = 32 |
| Timestamp buffer size. | |
| constexpr F_long | DATE_SIZE = 32 |
| Date buffer size. | |
| constexpr F_long | TIME_SIZE = 32 |
| Time buffer size. | |
| using fray::log::dateBuffer = F_char[DATE_SIZE] |
Date buffer type.
Definition at line 133 of file log_manager.hpp.
| using fray::log::Sink = std::function<void(const F_char *PID, const F_char *level, F_long thread, const std::string &project, const F_char *message, bool consoleVisible)> |
Receives each printed line synchronously on the logging thread; it must not log. The sink runs without the output or sink mutex held; concurrent calls may overlap.
| PID | Borrowed process label. |
| level | Borrowed severity label. |
| thread | Calling thread's logging id. |
| project | Calling thread's project tag; empty denotes the application. |
| message | Borrowed formatted message, valid for the call. |
| consoleVisible | Whether the line may be shown in the Console. |
Definition at line 241 of file log_manager.hpp.
| using fray::log::timeBuffer = F_char[TIME_SIZE] |
Time buffer type.
Definition at line 141 of file log_manager.hpp.
Timestamp buffer type.
Definition at line 125 of file log_manager.hpp.
|
inline |
Whether the calling thread's log entries may be shown in the Console.
Definition at line 368 of file log_manager.hpp.
Log error for Electron.
| fmt | Format string. |
| ... | Variadic args. |
Definition at line 496 of file log_manager.hpp.
Log fatal for Electron.
| fmt | Format string. |
| ... | Variadic args. |
Definition at line 511 of file log_manager.hpp.
Log info for Electron.
| fmt | Format string. |
| ... | Variadic args. |
Definition at line 466 of file log_manager.hpp.
Log warning for Electron.
| fmt | Format string. |
| ... | Variadic args. |
Definition at line 481 of file log_manager.hpp.
Log error for Engine.
| fmt | Format string. |
| ... | Variadic args. |
Definition at line 577 of file log_manager.hpp.
Log fatal for Engine.
| fmt | Format string. |
| ... | Variadic args. |
Definition at line 592 of file log_manager.hpp.
Log info for Engine.
| fmt | Format string. |
| ... | Variadic args. |
Definition at line 526 of file log_manager.hpp.
|
inline |
Print an Engine info line without interpreting the message as a format string.
| message | Preformatted message text. |
Definition at line 551 of file log_manager.hpp.
|
inline |
Marks the start of a log session under the calling thread's project tag. The Engine records it as a session row, which the Console shows as a divider before the session's entries.
| name | "Fray" for the application, or the project's name. |
Definition at line 541 of file log_manager.hpp.
Log warning for Engine.
| fmt | Format string. |
| ... | Variadic args. |
Definition at line 562 of file log_manager.hpp.
|
inline |
Write "[HH:MM:SS:mmm] [YY.MM.DD]" into buffer.
| timestamp | Output buffer (>=32 bytes). |
| now | Time point formatted in local time; defaults to the current time. |
Definition at line 148 of file log_manager.hpp.
Write "YY.MM.DD" into buffer.
| date | Output buffer (>=32 bytes). |
Definition at line 174 of file log_manager.hpp.
|
inline |
Write "HH:MM:SS.mmm" into buffer.
| time | Output buffer (>=32 bytes). |
| now | Time point formatted in local time; defaults to the current time. |
Definition at line 197 of file log_manager.hpp.
|
inline |
Print a formatted log line with PID, level and colors. Serializes and flushes stdout, then invokes a snapshot of the sink on the calling thread without holding either mutex. The sink must not log and may run concurrently.
| PID | PID label (e.g., "ENG", "ELC"). |
| PIDColor | ANSI color for PID. |
| level | Level label (e.g., "INF"). |
| levelColor | ANSI color for level. |
| message | Preformatted message text. |
Definition at line 397 of file log_manager.hpp.
Replace the sink; an empty function removes it. Locks sinkMutex; an in-flight logging call may still invoke the previous sink.
| sink | Callback to own and invoke after printing, or an empty function to remove it. |
Definition at line 268 of file log_manager.hpp.
|
inline |
Return the mutex protecting access to the shared sink slot.
Definition at line 246 of file log_manager.hpp.
|
inline |
Return the shared sink slot; callers must hold sinkMutex when accessing it.
Definition at line 255 of file log_manager.hpp.
|
inline |
Whether the calling thread's printed lines skip the sink, so they reach stdout only.
Definition at line 334 of file log_manager.hpp.
|
inline |
Small sequential id for the calling thread, assigned on its first call (the first caller is 0).
Definition at line 222 of file log_manager.hpp.
|
inline |
Return the calling thread's project tag; an empty tag denotes the application.
Definition at line 281 of file log_manager.hpp.
|
inline |
Format up to 1023 message bytes and delegate to printf().
| PID | PID label. |
| PIDColor | ANSI color for PID. |
| level | Level label. |
| levelColor | ANSI color for level. |
| fmt | Format string. |
| args | va_list of arguments. |
Definition at line 448 of file log_manager.hpp.
|
constexpr |
ANSI BG black.
Definition at line 84 of file log_manager.hpp.
|
constexpr |
ANSI BG blue.
Definition at line 100 of file log_manager.hpp.
|
constexpr |
ANSI BG cyan.
Definition at line 108 of file log_manager.hpp.
|
constexpr |
ANSI BG green.
Definition at line 92 of file log_manager.hpp.
|
constexpr |
ANSI BG magenta.
Definition at line 104 of file log_manager.hpp.
|
constexpr |
ANSI BG orange (256-color).
Definition at line 116 of file log_manager.hpp.
|
constexpr |
ANSI BG red.
Definition at line 88 of file log_manager.hpp.
|
constexpr |
ANSI BG white.
Definition at line 112 of file log_manager.hpp.
|
constexpr |
ANSI BG yellow.
Definition at line 96 of file log_manager.hpp.
|
constexpr |
ANSI blink.
Definition at line 38 of file log_manager.hpp.
|
constexpr |
ANSI bold.
Definition at line 30 of file log_manager.hpp.
|
constexpr |
ANSI FG black.
Definition at line 47 of file log_manager.hpp.
|
constexpr |
ANSI FG blue.
Definition at line 63 of file log_manager.hpp.
|
constexpr |
ANSI FG cyan.
Definition at line 71 of file log_manager.hpp.
|
constexpr |
ANSI FG green.
Definition at line 55 of file log_manager.hpp.
|
constexpr |
ANSI FG magenta.
Definition at line 67 of file log_manager.hpp.
|
constexpr |
ANSI FG orange (256-color).
Definition at line 79 of file log_manager.hpp.
|
constexpr |
ANSI FG red.
Definition at line 51 of file log_manager.hpp.
|
constexpr |
ANSI FG white.
Definition at line 75 of file log_manager.hpp.
|
constexpr |
ANSI FG yellow.
Definition at line 59 of file log_manager.hpp.
|
constexpr |
ANSI inverse.
Definition at line 42 of file log_manager.hpp.
|
constexpr |
ANSI reset code.
Definition at line 26 of file log_manager.hpp.
|
constexpr |
ANSI underline.
Definition at line 34 of file log_manager.hpp.
|
constexpr |
Date buffer size.
Definition at line 129 of file log_manager.hpp.
|
constexpr |
Time buffer size.
Definition at line 137 of file log_manager.hpp.
|
constexpr |
Timestamp buffer size.
Definition at line 121 of file log_manager.hpp.