log.h File Reference

#include "common.h"
#include "str.h"
#include "config.h"
#include <stdio.h>

Go to the source code of this file.
#define LOG_LEVEL_DEBUG   0
#define LOG_LEVEL_INFO   1
#define LOG_LEVEL_WARNING   2
#define LOG_LEVEL_ERROR   3
#define LOG_LEVEL_FATAL   4
#define LOG_LEVEL_SILENT   5
#define cp_assert(cond)
#define MAX_LOG_MESSAGE_LEN   0x10000
#define PRECISE_TIME   "3"
#define PRECISE_TIME_FORMAT   ".%0" PRECISE_TIME "ld"
#define DEBUGMSG()
CPROPS_DLL int cp_log_init (char *filename, int verbosity)
CPROPS_DLL int cp_log_reopen ()
CPROPS_DLL int cp_log_close ()
CPROPS_DLL void die (int code, const char *msg,...)
CPROPS_DLL void cp_log_set_time_format (char *time_format)
CPROPS_DLL void cp_log (const char *msg,...)
CPROPS_DLL void cp_nlog (size_t len, const char *msg,...)
CPROPS_DLL void cp_debug (char *msg,...)
CPROPS_DLL void cp_debuginfo (char *msg,...)
CPROPS_DLL void cp_info (char *msg,...)
CPROPS_DLL void cp_warn (char *msg,...)
CPROPS_DLL void cp_error (int code, char *msg,...)
CPROPS_DLL void cp_perror (int code, int errno_code, char *msg,...)
CPROPS_DLL void cp_fatal (int code, char *msg,...)
CPROPS_DLL void cp_dump (int log_level, cp_string *str)
CPROPS_DLL void cp_ndump (int log_level, cp_string *str, size_t len)


Detailed Description

libcprops logging facilities

cp_log_init(filename, level) should be called on startup with a log file name and a log level. the following macros may be used for logging messages.

before exiting, cp_log_close() should be called to ensure the log is flushed.

Definition in file log.h.


Define Documentation

#define LOG_LEVEL_DEBUG   0

debug level

Definition at line 32 of file log.h.

Referenced by cp_debug(), and cp_debuginfo().

#define LOG_LEVEL_ERROR   3

quit - severe errors only

Definition at line 38 of file log.h.

Referenced by cp_error(), and cp_perror().

#define LOG_LEVEL_FATAL   4

very quiet - report fatal errors only

Definition at line 40 of file log.h.

Referenced by cp_fatal().

#define LOG_LEVEL_INFO   1

normal log level

Definition at line 34 of file log.h.

Referenced by cp_http_response_write(), and cp_info().

#define LOG_LEVEL_SILENT   5

no logging

Definition at line 42 of file log.h.

#define LOG_LEVEL_WARNING   2

relatively quiet - warnings only

Definition at line 36 of file log.h.

Referenced by cp_warn().

#define PRECISE_TIME   "3"

precision of seconds: undefine or use 1-6

Definition at line 59 of file log.h.


Function Documentation

CPROPS_DLL void cp_dump ( int  log_level,
cp_string str 
)

hex dump a cp_string

Definition at line 669 of file log.c.

References CHARS_PER_LINE, and LINELEN.

Referenced by cp_ndump().

CPROPS_DLL void cp_error ( int  code,
char *  msg,
  ... 
)

print out a LOG_LEVEL_ERROR log message

Definition at line 467 of file log.c.

References cp_hashtable_get(), and LOG_LEVEL_ERROR.

Referenced by cp_client_connect(), cp_client_reopen(), cp_client_write(), cp_connection_descriptor_create(), cp_connection_descriptor_write(), cp_connection_descrpitor_read(), cp_db_connection_close_statement(), cp_db_connection_commit(), cp_db_connection_escape_binary(), cp_db_connection_escape_string(), cp_db_connection_pool_create(), cp_db_connection_prepare_statement(), cp_db_connection_rollback(), cp_db_connection_set_autocommit(), cp_db_connection_set_fetch_size(), cp_db_connection_set_read_result_set_at_once(), cp_db_connection_unescape_binary(), cp_dbms_get_data_source(), cp_dbms_get_data_source_prm(), cp_http_service_create(), cp_http_thread_fn(), cp_httpclient_fetch_ctl_exec(), cp_httpclient_init(), cp_httpsocket_create(), cp_index_map_reindex(), cp_multimap_find_by_index(), cp_multimap_get_by_index(), cp_multimap_remove_by_index(), cp_pooled_thread_create(), cp_pooled_thread_run_task(), cp_result_set_get_field_types(), cp_result_set_get_headers(), cp_result_set_next(), cp_socket_create(), cp_socket_select_callback_impl(), cp_socket_select_threadpool_impl(), cp_string_create(), cp_thread_pool_create(), and cp_url_descriptor_parse().

CPROPS_DLL void cp_fatal ( int  code,
char *  msg,
  ... 
)

print out a LOG_LEVEL_FATAL log message and exit. if log_level is LOG_LEVEL_SILENT, the error message is supressed but the process still exits.

Definition at line 570 of file log.c.

References cp_log_close(), and LOG_LEVEL_FATAL.

Referenced by cp_client_init(), cp_pooled_thread_client_interface_create(), cp_pooled_thread_scheduler_create(), cp_thread_pool_create(), and die().

CPROPS_DLL void cp_log ( const char *  msg,
  ... 
)

unconditionally log a message

Definition at line 244 of file log.c.

Referenced by cp_http_response_write(), and die().

CPROPS_DLL void cp_ndump ( int  log_level,
cp_string str,
size_t  len 
)

hex dump up to len bytes of a cp_string

Definition at line 730 of file log.c.

References cp_dump().

Referenced by cp_http_response_write().

CPROPS_DLL void cp_nlog ( size_t  len,
const char *  msg,
  ... 
)

unconditionally log a limited length message

Definition at line 259 of file log.c.

Referenced by cp_http_response_write().

CPROPS_DLL void cp_perror ( int  code,
int  errno_code,
char *  msg,
  ... 
)

print out a LOG_LEVEL_ERROR log message with an errno code

Definition at line 511 of file log.c.

References cp_hashtable_get(), and LOG_LEVEL_ERROR.

Referenced by cp_client_close(), cp_client_create(), cp_client_reopen(), cp_http_thread_fn(), cp_index_map_reindex(), cp_socket_connection_close(), cp_socket_listen(), cp_socket_select_callback_impl(), and cp_socket_select_threadpool_impl().

CPROPS_DLL void cp_warn ( char *  msg,
  ... 
)

print out a LOG_LEVEL_WARNING log message

Definition at line 453 of file log.c.

References LOG_LEVEL_WARNING.

Referenced by cp_http_service_delete().


Generated on Mon Dec 5 23:00:22 2011 for cprops by  doxygen 1.4.7