libcprops logging facilities More...
#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 |
debug level | |
#define | LOG_LEVEL_INFO 1 |
normal log level | |
#define | LOG_LEVEL_WARNING 2 |
relatively quiet - warnings only | |
#define | LOG_LEVEL_ERROR 3 |
quit - severe errors only | |
#define | LOG_LEVEL_FATAL 4 |
very quiet - report fatal errors only | |
#define | LOG_LEVEL_SILENT 5 |
no logging | |
#define | cp_assert(cond) (cond == 0 ? die(1, "assertion %s failed, in %s line %d\n", #cond, __FILE__, __LINE__) : 0) |
#define | MAX_LOG_MESSAGE_LEN 0x10000 |
#define | PRECISE_TIME "3" |
precision of seconds: undefine or use 1-6 | |
#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 (void) |
CPROPS_DLL int | cp_log_close (void) |
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,...) |
unconditionally log a message | |
CPROPS_DLL void | cp_nlog (size_t len, const char *msg,...) |
unconditionally log a limited length message | |
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,...) |
print out a LOG_LEVEL_WARNING log message | |
CPROPS_DLL void | cp_error (int code, char *msg,...) |
print out a LOG_LEVEL_ERROR log message | |
CPROPS_DLL void | cp_perror (int code, int errno_code, char *msg,...) |
print out a LOG_LEVEL_ERROR log message with an errno code | |
CPROPS_DLL void | cp_fatal (int code, char *msg,...) |
print out a LOG_LEVEL_FATAL log message and exit. | |
CPROPS_DLL void | cp_dump (int log_level, cp_string *str) |
hex dump a cp_string | |
CPROPS_DLL void | cp_ndump (int log_level, cp_string *str, size_t len) |
hex dump up to len bytes of a cp_string |
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.
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.
References LOG_LEVEL_FATAL.
Referenced by cp_client_init().