ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
format.h File Reference

Go to the source code of this file.

Data Structures

struct  log_format_spec_t
 One literal or conversion token in a compiled log format. More...
struct  log_template_t
 Compiled log format ready for use in log_template_apply(). More...

Enumerations

enum  log_template_type_t {
  LOG_FORMAT_LITERAL , LOG_FORMAT_TIME , LOG_FORMAT_LEVEL , LOG_FORMAT_LEVEL_ALIGNED ,
  LOG_FORMAT_FILE , LOG_FORMAT_FILE_RELATIVE , LOG_FORMAT_LINE , LOG_FORMAT_FUNC ,
  LOG_FORMAT_TID , LOG_FORMAT_TNAME , LOG_FORMAT_MESSAGE , LOG_FORMAT_COLORLOG_LEVEL ,
  LOG_FORMAT_COLOR , LOG_FORMAT_COLORED_MESSAGE , LOG_FORMAT_MICROSECONDS , LOG_FORMAT_NANOSECONDS ,
  LOG_FORMAT_STRFTIME_CODE , LOG_FORMAT_NEWLINE
}
 One literal or conversion token in a compiled log format. More...

Functions

log_template_t * log_template_parse (const char *format_str, bool console_only)
 Parse a format string into compiled format structure.
void log_template_free (log_template_t *format)
 Free compiled format structure.
int log_template_apply (const log_template_t *format, char *buf, size_t buf_size, log_level_t level, const char *timestamp, const char *file, int line, const char *func, uint64_t tid, const char *message, bool use_colors, uint64_t time_nanoseconds)
 Apply format to a log entry and write result to buffer.

Enumeration Type Documentation

◆ log_template_type_t

One literal or conversion token in a compiled log format.

Compiled log format ready for use in log_template_apply()

Types of format specifiers that can appear in a format string

Enumerator
LOG_FORMAT_LITERAL 
LOG_FORMAT_TIME 
LOG_FORMAT_LEVEL 
LOG_FORMAT_LEVEL_ALIGNED 
LOG_FORMAT_FILE 
LOG_FORMAT_FILE_RELATIVE 
LOG_FORMAT_LINE 
LOG_FORMAT_FUNC 
LOG_FORMAT_TID 
LOG_FORMAT_TNAME 
LOG_FORMAT_MESSAGE 
LOG_FORMAT_COLORLOG_LEVEL 
LOG_FORMAT_COLOR 
LOG_FORMAT_COLORED_MESSAGE 
LOG_FORMAT_MICROSECONDS 
LOG_FORMAT_NANOSECONDS 
LOG_FORMAT_STRFTIME_CODE 
LOG_FORMAT_NEWLINE 

Definition at line 27 of file log/format.h.

27 {
28 LOG_FORMAT_LITERAL, /* Plain text (no % prefix) */
29 LOG_FORMAT_TIME, /* %time(fmt) - custom time format */
30 LOG_FORMAT_LEVEL, /* %level - log level as string */
31 LOG_FORMAT_LEVEL_ALIGNED, /* %level_aligned - log level padded */
32 LOG_FORMAT_FILE, /* %file - file path */
33 LOG_FORMAT_FILE_RELATIVE, /* %file_relative - file path relative to project root */
34 LOG_FORMAT_LINE, /* %line - line number */
35 LOG_FORMAT_FUNC, /* %func - function name */
36 LOG_FORMAT_TID, /* %tid - thread ID */
37 LOG_FORMAT_TNAME, /* %tname - thread name (from debug registry) */
38 LOG_FORMAT_MESSAGE, /* %message - log message */
39 LOG_FORMAT_COLORLOG_LEVEL, /* %colorlog_level_string_to_color - color code */
40 LOG_FORMAT_COLOR, /* %color(LEVEL, content) - colorize content using LEVEL's color */
41 LOG_FORMAT_COLORED_MESSAGE, /* %colored_message - message with things like filenames and 0x numbers colored */
42 LOG_FORMAT_MICROSECONDS, /* %ms - microseconds component of current time (000000-999999) */
43 LOG_FORMAT_NANOSECONDS, /* %ns - nanoseconds component of current time (000000000-999999999) */
44 LOG_FORMAT_STRFTIME_CODE, /* %H, %M, %S, %A, %B, etc. - strftime format codes */
45 LOG_FORMAT_NEWLINE, /* Platform-aware newline (\n) */
log_template_type_t
One literal or conversion token in a compiled log format.
Definition log/format.h:27
@ LOG_FORMAT_LEVEL
Definition log/format.h:30
@ LOG_FORMAT_COLOR
Definition log/format.h:40
@ LOG_FORMAT_NEWLINE
Definition log/format.h:45
@ LOG_FORMAT_FILE_RELATIVE
Definition log/format.h:33
@ LOG_FORMAT_LINE
Definition log/format.h:34
@ LOG_FORMAT_MICROSECONDS
Definition log/format.h:42
@ LOG_FORMAT_TID
Definition log/format.h:36
@ LOG_FORMAT_COLORED_MESSAGE
Definition log/format.h:41
@ LOG_FORMAT_LITERAL
Definition log/format.h:28
@ LOG_FORMAT_COLORLOG_LEVEL
Definition log/format.h:39
@ LOG_FORMAT_MESSAGE
Definition log/format.h:38
@ LOG_FORMAT_TIME
Definition log/format.h:29
@ LOG_FORMAT_LEVEL_ALIGNED
Definition log/format.h:31
@ LOG_FORMAT_FUNC
Definition log/format.h:35
@ LOG_FORMAT_NANOSECONDS
Definition log/format.h:43
@ LOG_FORMAT_TNAME
Definition log/format.h:37
@ LOG_FORMAT_STRFTIME_CODE
Definition log/format.h:44
@ LOG_FORMAT_FILE
Definition log/format.h:32