Basic Logger.
More...
#include <stdio.h>
#include <stdarg.h>
#include "apt.h"
Go to the source code of this file.
|
enum | apt_log_priority_e {
APT_PRIO_EMERGENCY,
APT_PRIO_ALERT,
APT_PRIO_CRITICAL,
APT_PRIO_ERROR,
APT_PRIO_WARNING,
APT_PRIO_NOTICE,
APT_PRIO_INFO,
APT_PRIO_DEBUG,
APT_PRIO_COUNT
} |
|
enum | apt_log_header_e {
APT_LOG_HEADER_NONE = 0x00,
APT_LOG_HEADER_DATE = 0x01,
APT_LOG_HEADER_TIME = 0x02,
APT_LOG_HEADER_PRIORITY = 0x04,
APT_LOG_HEADER_MARK = 0x08,
APT_LOG_HEADER_THREAD = 0x10,
APT_LOG_HEADER_DEFAULT = APT_LOG_HEADER_DATE | APT_LOG_HEADER_TIME | APT_LOG_HEADER_PRIORITY
} |
|
enum | apt_log_output_e { APT_LOG_OUTPUT_NONE = 0x00,
APT_LOG_OUTPUT_CONSOLE = 0x01,
APT_LOG_OUTPUT_FILE = 0x02,
APT_LOG_OUTPUT_SYSLOG = 0x04
} |
|
enum | apt_log_masking_e { APT_LOG_MASKING_NONE,
APT_LOG_MASKING_COMPLETE,
APT_LOG_MASKING_ENCRYPTED
} |
|
|
apt_bool_t | apt_log_instance_create (apt_log_output_e mode, apt_log_priority_e priority, apr_pool_t *pool) |
|
apt_bool_t | apt_log_instance_load (const char *config_file, apr_pool_t *pool) |
|
apt_bool_t | apt_log_instance_destroy (void) |
|
apt_logger_t * | apt_log_instance_get (void) |
|
apt_bool_t | apt_log_instance_set (apt_logger_t *logger) |
|
void | apt_def_log_source_set (apt_log_source_t *log_source) |
|
apt_bool_t | apt_log_source_assign (const char *name, apt_log_source_t **log_source) |
|
apt_bool_t | apt_log_file_open (const char *dir_path, const char *file_name, apr_size_t max_file_size, apr_size_t max_file_count, apt_bool_t append, apr_pool_t *pool) |
|
apt_bool_t | apt_log_file_open_ex (const char *dir_path, const char *prefix, const char *config_file, apr_pool_t *pool) |
|
apt_bool_t | apt_log_file_close (void) |
|
apt_bool_t | apt_syslog_open (const char *prefix, const char *config_file, apr_pool_t *pool) |
|
apt_bool_t | apt_syslog_close (void) |
|
apt_bool_t | apt_log_output_mode_set (apt_log_output_e mode) |
|
apt_bool_t | apt_log_output_mode_check (apt_log_output_e mode) |
|
int | apt_log_output_mode_translate (char *str) |
|
apt_bool_t | apt_log_priority_set (apt_log_priority_e priority) |
|
apt_log_priority_e | apt_log_priority_translate (const char *str) |
|
apt_bool_t | apt_log_header_set (int header) |
|
int | apt_log_header_translate (char *str) |
|
apt_bool_t | apt_log_masking_set (apt_log_masking_e masking) |
|
apt_log_masking_e | apt_log_masking_get (void) |
|
apt_log_masking_e | apt_log_masking_translate (const char *str) |
|
const char * | apt_log_data_mask (const char *data_in, apr_size_t *length, apr_pool_t *pool) |
|
apt_bool_t | apt_log_ext_handler_set (apt_log_ext_handler_f handler) |
|
apt_bool_t | apt_log (apt_log_source_t *log_source, const char *file, int line, apt_log_priority_e priority, const char *format,...) |
|
apt_bool_t | apt_obj_log (apt_log_source_t *log_source, const char *file, int line, apt_log_priority_e priority, void *obj, const char *format,...) |
|
apt_bool_t | apt_va_log (apt_log_source_t *log_source, const char *file, int line, apt_log_priority_e priority, const char *format, va_list arg_ptr) |
|
◆ APT_LOG_MARK
Default log mark providing log source, file and line information
◆ APT_LOG_MARK_DECLARE
#define APT_LOG_MARK_DECLARE |
( |
|
LOG_SOURCE | ) |
LOG_SOURCE,__FILE__,__LINE__ |
Declaration of log mark to be used by custom log sources
◆ APT_LOG_SOURCE_DECLARE
#define APT_LOG_SOURCE_DECLARE |
( |
|
SCOPE, |
|
|
|
LOG_SOURCE |
|
) |
| |
Value: SCOPE##_DECLARE(void) LOG_SOURCE##_init();
struct apt_log_source_t apt_log_source_t
Definition: apt_log.h:37
Use this macro in a header file to declare a custom log source
◆ APT_LOG_SOURCE_IMPLEMENT
#define APT_LOG_SOURCE_IMPLEMENT |
( |
|
SCOPE, |
|
|
|
LOG_SOURCE, |
|
|
|
LOG_SOURCE_TAG |
|
) |
| |
Value:apt_log_source_t def_log_source
struct apt_log_source_t apt_log_source_t
Definition: apt_log.h:37
apt_bool_t apt_log_source_assign(const char *name, apt_log_source_t **log_source)
Use this macro in a source file to implement a custom log source
◆ APT_NAMESID_FMT
#define APT_NAMESID_FMT "%s " APT_SID_FMT |
Format to log names and identifiers
◆ APT_NAMESIDRES_FMT
#define APT_NAMESIDRES_FMT "%s " APT_SIDRES_FMT |
Format to log names, identifiers and resources
◆ APT_PTR_FMT
#define APT_PTR_FMT "0x%lx" |
Format to log pointer values
◆ APT_PTRSID_FMT
Format to log pointers and identifiers
◆ APT_SID_FMT
#define APT_SID_FMT "<%s>" |
Format to log string identifiers
◆ APT_SIDRES_FMT
#define APT_SIDRES_FMT "<%s@%s>" |
Format to log string identifiers and resources
◆ MAX_LOG_FILE_COUNT
#define MAX_LOG_FILE_COUNT 100 |
Default max number of log files used in rotation
◆ MAX_LOG_FILE_SIZE
#define MAX_LOG_FILE_SIZE (8 * 1024 * 1024) |
Default max size of the log file (8Mb)
◆ apt_log_ext_handler_f
typedef apt_bool_t(* apt_log_ext_handler_f) (const char *file, int line, const char *obj, apt_log_priority_e priority, const char *format, va_list arg_ptr) |
Prototype of extended log handler function
◆ apt_log_source_t
Opaque log source declaration
◆ apt_logger_t
Opaque logger declaration
◆ apt_log_header_e
Header (format) of log messages
Enumerator |
---|
APT_LOG_HEADER_NONE | disable optional headers output
|
APT_LOG_HEADER_DATE | enable date output
|
APT_LOG_HEADER_TIME | enable time output
|
APT_LOG_HEADER_PRIORITY | enable priority name output
|
APT_LOG_HEADER_MARK | enable file:line mark output
|
APT_LOG_HEADER_THREAD | enable thread identifier output
|
◆ apt_log_masking_e
Masking mode of private data
Enumerator |
---|
APT_LOG_MASKING_NONE | log everything as is
|
APT_LOG_MASKING_COMPLETE | mask private data completely
|
APT_LOG_MASKING_ENCRYPTED | encrypt private data
|
◆ apt_log_output_e
Mode of log output
Enumerator |
---|
APT_LOG_OUTPUT_NONE | disable logging
|
APT_LOG_OUTPUT_CONSOLE | enable console output
|
APT_LOG_OUTPUT_FILE | enable log file output
|
APT_LOG_OUTPUT_SYSLOG | enable syslog output
|
◆ apt_log_priority_e
Priority of log messages ordered from highest priority to lowest (rfc3164)
Enumerator |
---|
APT_PRIO_EMERGENCY | system is unusable
|
APT_PRIO_ALERT | action must be taken immediately
|
APT_PRIO_CRITICAL | critical condition
|
APT_PRIO_ERROR | error condition
|
APT_PRIO_WARNING | warning condition
|
APT_PRIO_NOTICE | normal, but significant condition
|
APT_PRIO_INFO | informational message
|
APT_PRIO_DEBUG | debug-level message
|
APT_PRIO_COUNT | number of priorities
|
◆ apt_def_log_source_set()
Set the default log source.
- Parameters
-
log_source | the log source to set |
◆ apt_log()
Do logging.
- Parameters
-
log_source | the log source |
file | the file name log entry is generated from |
line | the line number log entry is generated from |
priority | the priority of the entire log entry |
format | the format of the entire log entry |
◆ apt_log_data_mask()
const char* apt_log_data_mask |
( |
const char * |
data_in, |
|
|
apr_size_t * |
length, |
|
|
apr_pool_t * |
pool |
|
) |
| |
Mask private data based on the masking mode.
- Parameters
-
data_in | the data to mask |
length | the length of the data to mask on input, the length of the masked data on output |
pool | the memory pool to use if needed |
- Returns
- The masked data.
◆ apt_log_ext_handler_set()
Set the extended external log handler.
- Parameters
-
handler | the handler to pass log events to |
◆ apt_log_file_close()
◆ apt_log_file_open()
apt_bool_t apt_log_file_open |
( |
const char * |
dir_path, |
|
|
const char * |
file_name, |
|
|
apr_size_t |
max_file_size, |
|
|
apr_size_t |
max_file_count, |
|
|
apt_bool_t |
append, |
|
|
apr_pool_t * |
pool |
|
) |
| |
Open the log file.
- Parameters
-
dir_path | the path to the log directory |
file_name | the name of the log file |
max_file_size | the max size of the log file |
max_file_count | the max number of files used in log rotation |
append | whether to append or to truncate (start over) the log file |
pool | the memory pool to use |
- Deprecated:
- See also
- apt_log_file_open_ex()
◆ apt_log_file_open_ex()
apt_bool_t apt_log_file_open_ex |
( |
const char * |
dir_path, |
|
|
const char * |
prefix, |
|
|
const char * |
config_file, |
|
|
apr_pool_t * |
pool |
|
) |
| |
Open the log file (extended version).
- Parameters
-
dir_path | the path to the log directory |
prefix | the prefix used to compose the log file name |
config_file | the path to configuration file to load settings from |
pool | the memory pool to use |
◆ apt_log_header_set()
Set the header (format) for log messages.
- Parameters
-
header | the header to set (used as bitmask) |
◆ apt_log_header_translate()
int apt_log_header_translate |
( |
char * |
str | ) |
|
Translate the header string to bitmask of apt_log_header_e values.
- Parameters
-
str | the string to translate |
◆ apt_log_instance_create()
Create the singleton instance of the logger.
- Parameters
-
mode | the log output mode |
priority | the log priority level |
pool | the memory pool to use |
◆ apt_log_instance_destroy()
Destroy the singleton instance of the logger.
◆ apt_log_instance_get()
Get the singleton instance of the logger.
◆ apt_log_instance_load()
apt_bool_t apt_log_instance_load |
( |
const char * |
config_file, |
|
|
apr_pool_t * |
pool |
|
) |
| |
Create and load the singleton instance of the logger.
- Parameters
-
config_file | the path to configuration file to load settings from |
pool | the memory pool to use |
◆ apt_log_instance_set()
Set the singleton instance of the logger.
- Parameters
-
◆ apt_log_masking_get()
Get the current masking mode of private data.
◆ apt_log_masking_set()
Set the masking mode of private data.
- Parameters
-
masking | the masking mode to set |
◆ apt_log_masking_translate()
Translate the masking mode string to enum.
- Parameters
-
str | the string to translate |
◆ apt_log_output_mode_check()
Check the logging output mode to be enabled (set) or not.
- Parameters
-
◆ apt_log_output_mode_set()
Set the logging output mode.
- Parameters
-
◆ apt_log_output_mode_translate()
int apt_log_output_mode_translate |
( |
char * |
str | ) |
|
Translate the output mode string to bitmask of apt_log_output_e values.
- Parameters
-
str | the string to translate |
◆ apt_log_priority_set()
Set the logging priority (log level).
- Parameters
-
priority | the priority to set |
◆ apt_log_priority_translate()
Translate the priority (log level) string to enum.
- Parameters
-
str | the string to translate |
◆ apt_log_source_assign()
Find and assign log source by its name.
- Parameters
-
name | the unique name associated to the log source |
log_source | the log source to be returned, if found |
◆ apt_obj_log()
Do logging (this version uses an object externally associated with the logger).
- Parameters
-
log_source | the log source |
file | the file name log entry is generated from |
line | the line number log entry is generated from |
priority | the priority of the entire log entry |
obj | the associated object |
format | the format of the entire log entry |
◆ apt_syslog_close()
◆ apt_syslog_open()
apt_bool_t apt_syslog_open |
( |
const char * |
prefix, |
|
|
const char * |
config_file, |
|
|
apr_pool_t * |
pool |
|
) |
| |
Open the syslog.
- Parameters
-
prefix | the prefix used to compose the log file name |
config_file | the path to configuration file to load settings from |
pool | the memory pool to use |
◆ apt_va_log()
Do logging (this version accepts va_list argument).
- Parameters
-
log_source | the log source |
file | the file name log entry is generated from |
line | the line number log entry is generated from |
priority | the priority of the entire log entry |
format | the format of the entire log entry |
arg_ptr | the arguments |
◆ def_log_source
Default (globally available) log source