docs/src/modules.md

changeset 295
7fc65395188e
parent 294
bfa935ab7f85
child 297
ba760f2195c3
equal deleted inserted replaced
294:bfa935ab7f85 295:7fc65395188e
244 *Required modules:* [Map](#map), [String](#string) 244 *Required modules:* [Map](#map), [String](#string)
245 245
246 The logging module comes with some predefined log levels and allows some more 246 The logging module comes with some predefined log levels and allows some more
247 customization. You may choose if you want to get timestamps or source file and 247 customization. You may choose if you want to get timestamps or source file and
248 line number logged automatically when outputting a message. 248 line number logged automatically when outputting a message.
249 249 The following function call initializes a debug logger with all of the above
250 information:
251 ```C
252 log = ucx_logger_new(stdout, UCX_LOGGER_DEBUG,
253 UCX_LOGGER_LEVEL | UCX_LOGGER_TIMESTAMP | UCX_LOGGER_SOURCE);
254 ```
255 Afterwards you can use this logger with the predefined macros
256 ```C
257 ucx_logger_trace(log, "Verbose output");
258 ucx_logger_debug(log, "Debug message");
259 ucx_logger_info(log, "Information");
260 ucx_logger_warn(log, "Warning");
261 ucx_logger_error(log, "Error message");
262 ```
263 or you use
264 ```C
265 ucx_logger_log(log, CUSTOM_LEVEL, "Some message")
266 ```
267 When you use your custom log level, don't forget to register it with
268 ```C
269 ucx_logger_register_level(log, CUSTOM_LEVEL, "CUSTOM")
270 ```
271 where the last argument must be a string literal.
250 272
251 ## Map 273 ## Map
252 274
253 *Header file:* [map.h](api/map_8h.html) 275 *Header file:* [map.h](api/map_8h.html)
254 *Required modules:* [Allocator](#allocator), [String](#string) 276 *Required modules:* [Allocator](#allocator), [String](#string)
306 /* Don't forget to free the values before freeing the map */ 328 /* Don't forget to free the values before freeing the map */
307 ucx_map_free_content(myprops, NULL); 329 ucx_map_free_content(myprops, NULL);
308 ucx_map_free(myprops); 330 ucx_map_free(myprops);
309 fclose(file); 331 fclose(file);
310 ``` 332 ```
333
311 ## Stack 334 ## Stack
312 335
313 *Header file:* [stack.h](api/stack_8h.html) 336 *Header file:* [stack.h](api/stack_8h.html)
314 *Required modules:* [Allocator](#allocator) 337 *Required modules:* [Allocator](#allocator)
315 338

mercurial