apt_log.h File Reference

Basic Logger. More...

#include <stdio.h>
#include <stdarg.h>
#include "apt.h"

Go to the source code of this file.

Defines

#define MAX_LOG_FILE_SIZE   (8 * 1024 * 1024)
#define MAX_LOG_FILE_COUNT   10
#define APT_LOG_MARK   __FILE__,__LINE__
#define APT_PTR_FMT   "0x%x"
#define APT_SID_FMT   "<%s>"
#define APT_SIDRES_FMT   "<%s@%s>"
#define APT_PTRSID_FMT   APT_PTR_FMT" "APT_SID_FMT
#define APT_NAMESID_FMT   "%s "APT_SID_FMT
#define APT_NAMESIDRES_FMT   "%s "APT_SIDRES_FMT

Typedefs

typedef struct apt_logger_t apt_logger_t
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)

Enumerations

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 }
enum  apt_log_masking_e { APT_LOG_MASKING_NONE, APT_LOG_MASKING_COMPLETE, APT_LOG_MASKING_ENCRYPTED }

Functions

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_tapt_log_instance_get (void)
apt_bool_t apt_log_instance_set (apt_logger_t *logger)
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_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 ()
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 (const char *file, int line, apt_log_priority_e priority, const char *format,...)
apt_bool_t apt_obj_log (const char *file, int line, apt_log_priority_e priority, void *obj, const char *format,...)

Detailed Description

Basic Logger.


Define Documentation

#define APT_LOG_MARK   __FILE__,__LINE__

File:line mark

#define APT_NAMESID_FMT   "%s "APT_SID_FMT

Format to log pointers and identifiers

#define APT_NAMESIDRES_FMT   "%s "APT_SIDRES_FMT

Format to log names, identifiers and resources

#define APT_PTR_FMT   "0x%x"

Format to log pointer values

#define APT_PTRSID_FMT   APT_PTR_FMT" "APT_SID_FMT

Format to log pointers and identifiers

#define APT_SID_FMT   "<%s>"

Format to log string identifiers

#define APT_SIDRES_FMT   "<%s@%s>"

Format to log string identifiers and resources

#define MAX_LOG_FILE_COUNT   10

Default max number of rotated log files

#define MAX_LOG_FILE_SIZE   (8 * 1024 * 1024)

Default max size of the log file (8Mb)


Typedef Documentation

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

typedef struct apt_logger_t apt_logger_t

Opaque logger declaration


Enumeration Type Documentation

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

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

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

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


Function Documentation

apt_bool_t apt_log ( const char *  file,
int  line,
apt_log_priority_e  priority,
const char *  format,
  ... 
)

Do logging.

Parameters:
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
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_bool_t apt_log_ext_handler_set ( apt_log_ext_handler_f  handler  ) 

Set the extended external log handler.

Parameters:
handler the handler to pass log events to
Remarks:
default logger is used to output the logs to stdout and/or log file, if external log handler isn't set
apt_bool_t apt_log_file_close ( void   ) 

Close the log file.

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
apt_bool_t apt_log_header_set ( int  header  ) 

Set the header (format) for log messages.

Parameters:
header the header to set (used as bitmask)
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_bool_t apt_log_instance_create ( apt_log_output_e  mode,
apt_log_priority_e  priority,
apr_pool_t *  pool 
)

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_bool_t apt_log_instance_destroy ( void   ) 

Destroy the singleton instance of the logger.

apt_logger_t* apt_log_instance_get ( void   ) 

Get the singleton instance of the logger.

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_bool_t apt_log_instance_set ( apt_logger_t logger  ) 

Set the singleton instance of the logger.

apt_log_masking_e apt_log_masking_get (  ) 

Get the current masking mode of private data.

apt_bool_t apt_log_masking_set ( apt_log_masking_e  masking  ) 

Set the masking mode of private data.

Parameters:
masking the masking mode to set
apt_log_masking_e apt_log_masking_translate ( const char *  str  ) 

Translate the masking mode string to enum.

Parameters:
str the string to translate
apt_bool_t apt_log_output_mode_check ( apt_log_output_e  mode  ) 

Check the logging output mode to be enabled (set) or not.

Parameters:
mode the mode to check
apt_bool_t apt_log_output_mode_set ( apt_log_output_e  mode  ) 

Set the logging output mode.

Parameters:
mode the mode to set
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_bool_t apt_log_priority_set ( apt_log_priority_e  priority  ) 

Set the logging priority (log level).

Parameters:
priority the priority to set
apt_log_priority_e apt_log_priority_translate ( const char *  str  ) 

Translate the priority (log level) string to enum.

Parameters:
str the string to translate
apt_bool_t apt_obj_log ( const char *  file,
int  line,
apt_log_priority_e  priority,
void *  obj,
const char *  format,
  ... 
)

Do logging.

Parameters:
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
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 25 Mar 2013 for UniMRCP by  doxygen 1.6.1