|
cwist
Modern C web framework with libttak runtime
|
#include <cwist/sys/app/logger.h>#include <cwist/core/mem/alloc.h>#include "log_async.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>
Go to the source code of this file.
Macros | |
| #define | _POSIX_C_SOURCE 200809L |
Functions | |
| cwist_logger * | cwist_logger_create (const char *name) |
| Creates a logger instance. | |
| void | cwist_logger_destroy (cwist_logger *log) |
| Destroys a logger instance and frees its name. | |
| void | cwist_logger_set_level (cwist_logger *log, cwist_log_level_t level) |
| Sets the minimum log level that will be emitted. | |
| void | cwist_logger_set_colors (cwist_logger *log, bool enabled) |
| Enables or disables ANSI color output in log lines. | |
| void | cwist_logger_log (cwist_logger *log, cwist_log_level_t level, const char *fmt,...) |
| Logs a formatted message at the given level. | |
| void | cwist_logger_debug (cwist_logger *log, const char *fmt,...) |
| Logs a formatted message at DEBUG level on stdout. | |
| void | cwist_logger_info (cwist_logger *log, const char *fmt,...) |
| Logs a formatted message at INFO level on stdout. | |
| void | cwist_logger_warn (cwist_logger *log, const char *fmt,...) |
| Logs a formatted message at WARN level on stderr. | |
| void | cwist_logger_error (cwist_logger *log, const char *fmt,...) |
| Logs a formatted message at ERROR level on stderr. | |
| cwist_logger * cwist_logger_create | ( | const char * | name | ) |
Creates a logger instance.
Create a logger.
| name | Logger name copied into the instance; NULL selects "cwist". |
Definition at line 32 of file logger.c.
References cap, cwist_alloc(), cwist_free(), CWIST_LOG_INFO, cwist_strdup(), cwist_logger::level, cwist_logger::name, and cwist_logger::use_colors.
Referenced by cwist_app_create().
| void cwist_logger_debug | ( | cwist_logger * | log, |
| const char * | fmt, | ||
| ... | |||
| ) |
Logs a formatted message at DEBUG level on stdout.
Write a debug message.
| log | Logger to log through; NULL is safely ignored. |
| fmt | printf-style format string. |
Definition at line 154 of file logger.c.
References cap, and CWIST_LOG_DEBUG.
| void cwist_logger_destroy | ( | cwist_logger * | log | ) |
Destroys a logger instance and frees its name.
Destroy a logger.
| log | Logger to free; NULL is safely ignored. |
Definition at line 48 of file logger.c.
References cwist_free(), and cwist_logger::name.
Referenced by cwist_app_destroy().
| void cwist_logger_error | ( | cwist_logger * | log, |
| const char * | fmt, | ||
| ... | |||
| ) |
Logs a formatted message at ERROR level on stderr.
Write an error message.
| log | Logger to log through; NULL is safely ignored. |
| fmt | printf-style format string. |
Definition at line 187 of file logger.c.
References cap, and CWIST_LOG_ERROR.
| void cwist_logger_info | ( | cwist_logger * | log, |
| const char * | fmt, | ||
| ... | |||
| ) |
Logs a formatted message at INFO level on stdout.
Write an info message.
| log | Logger to log through; NULL is safely ignored. |
| fmt | printf-style format string. |
Definition at line 165 of file logger.c.
References cap, and CWIST_LOG_INFO.
| void cwist_logger_log | ( | cwist_logger * | log, |
| cwist_log_level_t | level, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Logs a formatted message at the given level.
Write a log message.
| log | Logger to log through; NULL is safely ignored. |
| level | Level of the message; messages below the logger's level are suppressed. |
| fmt | printf-style format string. |
Definition at line 143 of file logger.c.
References cap.
| void cwist_logger_set_colors | ( | cwist_logger * | log, |
| bool | enabled | ||
| ) |
Enables or disables ANSI color output in log lines.
Enable or disable colored output.
| log | Logger to configure; NULL is safely ignored. |
| enabled | true to colorize level prefixes, false for plain output. |
Definition at line 66 of file logger.c.
References cwist_logger::use_colors.
| void cwist_logger_set_level | ( | cwist_logger * | log, |
| cwist_log_level_t | level | ||
| ) |
Sets the minimum log level that will be emitted.
Set the minimum log level.
| log | Logger to configure; NULL is safely ignored. |
| level | New minimum level; messages below it are suppressed. |
Definition at line 58 of file logger.c.
References cwist_logger::level.
| void cwist_logger_warn | ( | cwist_logger * | log, |
| const char * | fmt, | ||
| ... | |||
| ) |
Logs a formatted message at WARN level on stderr.
Write a warning message.
| log | Logger to log through; NULL is safely ignored. |
| fmt | printf-style format string. |
Definition at line 176 of file logger.c.
References cap, and CWIST_LOG_WARN.