Logging and tracing module. More...
#include "Log.h"
#include "MQTTPacket.h"
#include "MQTTProtocol.h"
#include "MQTTProtocolClient.h"
#include "Messages.h"
#include "LinkedList.h"
#include "StackTrace.h"
#include "Thread.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#include <string.h>
#include <syslog.h>
#include <sys/stat.h>
#include <sys/time.h>
Go to the source code of this file.
Classes | |
struct | traceEntry |
Macros | |
#define | _unlink unlink |
#define | GETTIMEOFDAY 1 |
#define | MAX_FUNCTION_NAME_LENGTH 256 |
#define | min(A, B) ( (A) < (B) ? (A):(B)) |
Functions | |
void | Log (enum LOG_LEVELS log_level, int msgno, const char *format,...) |
static char * | Log_formatTraceEntry (traceEntry *cur_entry) |
int | Log_initialize (Log_nameValue *info) |
static void | Log_output (enum LOG_LEVELS log_level, const char *msg) |
static void | Log_posttrace (enum LOG_LEVELS log_level, traceEntry *cur_entry) |
static traceEntry * | Log_pretrace (void) |
void | Log_setTraceCallback (Log_traceCallback *callback) |
void | Log_setTraceLevel (enum LOG_LEVELS level) |
void | Log_stackTrace (enum LOG_LEVELS log_level, int msgno, int thread_id, int current_depth, const char *name, int line, int *rc) |
void | Log_terminate (void) |
static void | Log_trace (enum LOG_LEVELS log_level, const char *buf) |
Variables | |
struct timeval now_ts | last_ts |
static int | lines_written = 0 |
static mutex_type | log_mutex = &log_mutex_store |
static pthread_mutex_t | log_mutex_store = PTHREAD_MUTEX_INITIALIZER |
static int | max_lines_per_file = 1000 |
static char | msg_buf [512] |
static int | next_index = 0 |
static int | sametime_count = 0 |
static int | start_index = -1 |
static Log_traceCallback * | trace_callback = NULL |
static FILE * | trace_destination = NULL |
static char * | trace_destination_backup_name = NULL |
static char * | trace_destination_name = NULL |
static enum LOG_LEVELS | trace_output_level = INVALID_LEVEL |
static traceEntry * | trace_queue = NULL |
static int | trace_queue_size = 0 |
trace_settings_type | trace_settings |
Logging and tracing module.
Definition in file Log.c.
void Log | ( | enum LOG_LEVELS | log_level, |
int | msgno, | ||
const char * | format, | ||
... | |||
) |
Log a message. If possible, all messages should be indexed by message number, and the use of the format string should be minimized or negated altogether. If format is provided, the message number is only used as a message label.
log_level | the log level of the message |
msgno | the id of the message to use if the format string is NULL |
aFormat | the printf format string to be used if the message id does not exist |
... | the printf inserts |
|
static |
int Log_initialize | ( | Log_nameValue * | info | ) |
|
static |
|
static |
|
static |
void Log_setTraceCallback | ( | Log_traceCallback * | callback | ) |
void Log_setTraceLevel | ( | enum LOG_LEVELS | level | ) |
void Log_stackTrace | ( | enum LOG_LEVELS | log_level, |
int | msgno, | ||
int | thread_id, | ||
int | current_depth, | ||
const char * | name, | ||
int | line, | ||
int * | rc | ||
) |
The reason for this function is to make trace logging as fast as possible so that the function exit/entry history can be captured by default without unduly impacting performance. Therefore it must do as little as possible.
log_level | the log level of the message |
msgno | the id of the message to use if the format string is NULL |
aFormat | the printf format string to be used if the message id does not exist |
... | the printf inserts |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
trace_settings_type trace_settings |