21 {
22
23 {"log-file",
24 'L',
25 OPTION_TYPE_CALLBACK,
26 offsetof(options_t, log_file),
27 NULL,
28 0,
29 "Set FILE as path for log file (default: /tmp/ascii-chat-<mode>.log or Windows temp dir).",
30 "LOGGING",
31 "FILE",
32 false,
33 "ASCII_CHAT_LOG_FILE",
34 NULL,
36 false,
37 false,
38 OPTION_MODE_BINARY,
39 {0},
41 {"log-level",
42 '\0',
43 OPTION_TYPE_CALLBACK,
44 offsetof(options_t, log_level),
45 &default_log_level_value,
46 sizeof(log_level_t),
47 "Set log level: dev, debug, info, warn, error, fatal. Logs at or above this level are written.",
48 "LOGGING",
49 NULL,
50 false,
51 "ASCII_CHAT_LOG_LEVEL",
52 NULL,
54 false,
55 false,
56 OPTION_MODE_BINARY,
60 .input_type = OPTION_INPUT_ENUM},
61 NULL},
62 {"verbose",
63 'V',
64 OPTION_TYPE_CALLBACK,
65 offsetof(options_t, verbose_level),
66 0,
67 sizeof(unsigned short int),
68 "Increase log verbosity (stackable: -VV, -VVV).",
69 "LOGGING",
70 NULL,
71 false,
72 "ASCII_CHAT_VERBOSE",
73 NULL,
75 false,
76 true,
77 OPTION_MODE_BINARY,
78 {0},
79 NULL},
80 {"quiet",
81 'q',
82 OPTION_TYPE_BOOL,
83 offsetof(options_t, quiet),
84 &default_quiet_value,
86 "Disable console logging (log to file only).",
87 "LOGGING",
88 NULL,
89 false,
90 "ASCII_CHAT_QUIET",
91 NULL,
92 NULL,
93 false,
94 false,
95 OPTION_MODE_BINARY,
96 {0},
97 NULL},
98 {"grep",
99 '\0',
100 OPTION_TYPE_STRING,
101 offsetof(options_t, grep_pattern),
102 NULL,
103 sizeof(char *),
104 "Filter console logs with perl compatible regular expressions or fixed strings. "
105 "Format 1: /pattern/flags (with flags). Format 2: pattern (plain regex, no flags). "
106 "Flags (format 1 only): i(case-insensitive), m(multiline), s(dotall), x(extended), g(global highlight), "
107 "I(invert match), F(fixed string), A<n>(n lines after), B<n>(n lines before), C<n>(n lines of context). "
108 "Examples: '/error/i', 'error', '/panic/C5', 'warn|error', '/buffer pool/Fg'. Multiple --grep allowed (OR).",
109 "LOGGING",
110 "PATTERN",
111 false,
112 "ASCII_CHAT_GREP",
113 NULL,
114 NULL,
115 false,
116 false,
117 OPTION_MODE_BINARY,
118 {.examples = (const char *[]){"ERROR", "client\\.c", "network.*failed", NULL}},
119 NULL},
120 {"color-scheme",
121 '\0',
122 OPTION_TYPE_STRING,
123 offsetof(options_t, color_scheme_name),
124 OPT_COLOR_SCHEME_NAME_DEFAULT,
125 sizeof(((options_t *)0)->color_scheme_name),
126 "Color scheme for logging output. Built-in schemes: pastel, nord, solarized, dracula, gruvbox, "
127 "monokai, base16-default. All schemes with light variants auto-adapt to terminal background.",
128 "LOGGING",
129 "NAME",
130 false,
131 "ASCII_CHAT_COLOR_SCHEME",
132 NULL,
133 NULL,
134 false,
135 false,
136 OPTION_MODE_BINARY,
137 {.input_type = OPTION_INPUT_STRING},
138 NULL},
139 {"json",
140 '\0',
141 OPTION_TYPE_BOOL,
142 offsetof(options_t, json),
143 &default_json_value,
145 "Enable JSON logging (machine-readable NDJSON format). Disabled by default (text format).",
146 "LOGGING",
147 NULL,
148 false,
149 "ASCII_CHAT_JSON",
150 NULL,
151 NULL,
152 false,
153 true,
154 OPTION_MODE_BINARY,
155 {0},
156 NULL},
157 {"log-template",
158 '\0',
159 OPTION_TYPE_STRING,
160 offsetof(options_t, log_template),
161 NULL,
162 sizeof(((options_t *)0)->log_template),
163 "Custom log format string. Format specifiers: %time(fmt) - time with strftime format (see 'man 3 strftime' for "
164 "codes like %Y, %m, %d, %H, %M, %S); "
165 "%level - log level (DEV/DEBUG/INFO/WARN/ERROR/FATAL); %level_aligned - level padded to 5 chars; "
166 "%file - full file path; %file_relative - file path relative to project root; %line - line number; "
167 "%func - function name; %tid - thread ID; %message - log message; "
168 "%color(LEVEL, text) - colorize text using LEVEL's color from current scheme (e.g., %color(INFO, %tid)). "
169 "Example: '[%time(%Y-%m-%d %H:%M:%S)] [%level_aligned] %file_relative:%line %message'. "
170 "Escape %% for literal %, \\\\ for literal backslash. "
171 "Default: release mode '[%time(%H:%M:%S)] [%level_aligned] %message' or debug mode '[%time(%H:%M:%S)] "
172 "[%level_aligned] [tid:%tid] %file_relative:%line in %func(): %message'.",
173 "LOGGING",
174 "TEMPLATE",
175 false,
176 "ASCII_CHAT_LOG_TEMPLATE",
177 NULL,
178 NULL,
179 false,
180 false,
181 OPTION_MODE_BINARY,
182 {.input_type = OPTION_INPUT_STRING},
183 NULL},
184 {"log-format-console",
185 '\0',
186 OPTION_TYPE_BOOL,
187 offsetof(options_t, log_format_console_only),
188 NULL,
190 "Apply custom log template (--log-template) only to console output (file logs use default format). See "
191 "--log-template "
192 "for supported format specifiers.",
193 "LOGGING",
194 NULL,
195 false,
196 "ASCII_CHAT_LOG_FORMAT_CONSOLE",
197 NULL,
198 NULL,
199 false,
200 false,
201 OPTION_MODE_BINARY,
202 {0},
203 NULL},
204
205 REGISTRY_TERMINATOR()};
const void * get_default_log_file(asciichat_mode_t mode)
Get mode-specific default value for –log-file.
bool parse_verbose_flag(const char *arg, void *dest, char **error_msg)
bool parse_log_file(const char *arg, void *dest, char **error_msg)
bool parse_log_level(const char *arg, void *dest, char **error_msg)