Log.c File Reference

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>
Include dependency graph for Log.c:

Data Structures

struct  traceEntry

Defines

#define GETTIMEOFDAY   1
#define _unlink   unlink
 _unlink mapping for linux
#define min(A, B)   ( (A) < (B) ? (A):(B))
#define MAX_FUNCTION_NAME_LENGTH   256

Functions

static traceEntryLog_pretrace (void)
static char * Log_formatTraceEntry (traceEntry *cur_entry)
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 void Log_trace (enum LOG_LEVELS log_level, const char *buf)
int Log_initialize (Log_nameValue *info)
void Log_setTraceCallback (Log_traceCallback *callback)
void Log_setTraceLevel (enum LOG_LEVELS level)
void Log_terminate (void)
void Log (enum LOG_LEVELS log_level, int msgno, const char *format,...)
 Log a message.
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.

Variables

trace_settings_type trace_settings
static int start_index = -1
static int next_index = 0
static traceEntrytrace_queue = NULL
static int trace_queue_size = 0
static FILE * trace_destination = NULL
 flag to indicate if trace is to be sent to a stream
static char * trace_destination_name = NULL
 the name of the trace file
static char * trace_destination_backup_name = NULL
 the name of the backup trace file
static int lines_written = 0
 number of lines written to the current output file
static int max_lines_per_file = 1000
 maximum number of lines to write to one trace file
static enum LOG_LEVELS trace_output_level = INVALID_LEVEL
static Log_traceCallback * trace_callback = NULL
static int sametime_count = 0
struct timeval ts last_ts
static char msg_buf [512]
static pthread_mutex_t log_mutex_store = PTHREAD_MUTEX_INITIALIZER
static mutex_type log_mutex = &log_mutex_store

Detailed Description

Logging and tracing module.


Function Documentation

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.

Parameters:
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

Here is the call graph for this function:

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.

Parameters:
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

Here is the call graph for this function:


Variable Documentation

trace_settings_type trace_settings
Initial value:
{
        TRACE_MINIMUM,
        400,
        INVALID_LEVEL
}
 All Data Structures Files Functions Variables Typedefs Defines

Generated on 2 Jun 2018 for MQTT C Client Libraries Internals by  doxygen 1.6.1