Classes | Macros | Functions | Variables
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:

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 traceEntryLog_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_traceCallbacktrace_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 traceEntrytrace_queue = NULL
 
static int trace_queue_size = 0
 
trace_settings_type trace_settings
 

Detailed Description

Logging and tracing module.

Definition in file Log.c.

Macro Definition Documentation

#define _unlink   unlink

_unlink mapping for linux

Definition at line 59 of file Log.c.

#define GETTIMEOFDAY   1

Definition at line 44 of file Log.c.

#define MAX_FUNCTION_NAME_LENGTH   256

Definition at line 74 of file Log.c.

#define min (   A,
 
)    ( (A) < (B) ? (A):(B))

Definition at line 64 of file Log.c.

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_levelthe log level of the message
msgnothe id of the message to use if the format string is NULL
aFormatthe printf format string to be used if the message id does not exist
...the printf inserts

Definition at line 417 of file Log.c.

static char * Log_formatTraceEntry ( traceEntry cur_entry)
static

Definition at line 311 of file Log.c.

int Log_initialize ( Log_nameValue info)

Definition at line 132 of file Log.c.

static void Log_output ( enum LOG_LEVELS  log_level,
const char *  msg 
)
static

Definition at line 348 of file Log.c.

static void Log_posttrace ( enum LOG_LEVELS  log_level,
traceEntry cur_entry 
)
static

Definition at line 374 of file Log.c.

static traceEntry * Log_pretrace ( void  )
static

Definition at line 258 of file Log.c.

void Log_setTraceCallback ( Log_traceCallback callback)

Definition at line 218 of file Log.c.

void Log_setTraceLevel ( enum LOG_LEVELS  level)

Definition at line 224 of file Log.c.

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_levelthe log level of the message
msgnothe id of the message to use if the format string is NULL
aFormatthe printf format string to be used if the message id does not exist
...the printf inserts

Definition at line 448 of file Log.c.

void Log_terminate ( void  )

Definition at line 232 of file Log.c.

static void Log_trace ( enum LOG_LEVELS  log_level,
const char *  buf 
)
static

Definition at line 388 of file Log.c.

Variable Documentation

struct timeval now_ts last_ts

Definition at line 118 of file Log.c.

int lines_written = 0
static

number of lines written to the current output file

Definition at line 102 of file Log.c.

mutex_type log_mutex = &log_mutex_store
static

Definition at line 128 of file Log.c.

pthread_mutex_t log_mutex_store = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 127 of file Log.c.

int max_lines_per_file = 1000
static

maximum number of lines to write to one trace file

Definition at line 103 of file Log.c.

char msg_buf[512]
static

Definition at line 122 of file Log.c.

int next_index = 0
static

Definition at line 95 of file Log.c.

int sametime_count = 0
static

Definition at line 116 of file Log.c.

int start_index = -1
static

Definition at line 94 of file Log.c.

Log_traceCallback* trace_callback = NULL
static

Definition at line 105 of file Log.c.

FILE* trace_destination = NULL
static

flag to indicate if trace is to be sent to a stream

Definition at line 99 of file Log.c.

char* trace_destination_backup_name = NULL
static

the name of the backup trace file

Definition at line 101 of file Log.c.

char* trace_destination_name = NULL
static

the name of the trace file

Definition at line 100 of file Log.c.

enum LOG_LEVELS trace_output_level = INVALID_LEVEL
static

Definition at line 104 of file Log.c.

traceEntry* trace_queue = NULL
static

Definition at line 96 of file Log.c.

int trace_queue_size = 0
static

Definition at line 97 of file Log.c.

trace_settings_type trace_settings
Initial value:

Definition at line 67 of file Log.c.



plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:48