Nilorea Library
C utilities for networking, threading, graphics
n_nodup_log.c File Reference

generic no duplicate logging system More...

#include <stdio.h>
#include <stdarg.h>
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_str.h"
#include "nilorea/n_list.h"
#include "nilorea/n_hash.h"
#include "nilorea/n_nodup_log.h"
+ Include dependency graph for n_nodup_log.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 Feature test macro. More...
 
#define _GNU_SOURCE_WAS_NOT_DEFINED
 flag to detect if gnu source was set from our source file More...
 

Functions

void _n_nodup_log (int LEVEL, const char *file, const char *func, int line, const char *format,...)
 Logging function. More...
 
void _n_nodup_log_indexed (int LEVEL, const char *prefix, const char *file, const char *func, int line, const char *format,...)
 Logging function. More...
 
int check_n_log_dup (const char *log, const char *file, const char *func, int line)
 check if a log was already done or not at the given line, func, file More...
 
int check_n_log_dup_indexed (const char *log, const char *file, const char *func, int line, const char *prefix)
 check if a log was already done or not at the given line, func, file More...
 
int close_nodup_log ()
 Empty nodup logtable and close the no duplicate logging session. More...
 
int dump_nodup_log (char *file)
 Dump the duplicate error log hash table in a file. More...
 
int empty_nodup_table ()
 Empty the nodup internal table. More...
 
static char * get_nodup_indexed_key (const char *file, const char *func, const char *prefix, int line)
 internal, get a key for an indexed log entry More...
 
static char * get_nodup_key (const char *file, const char *func, int line)
 internal, get a key for a log entry More...
 
int init_nodup_log (int max)
 initialize the no duplicate logging system More...
 

Variables

static HASH_TABLE_n_nodup_table = NULL
 internal: no dup hash_table log save More...
 

Detailed Description

generic no duplicate logging system

Author
Castagnier Mickael
Date
2015-09-21

Definition in file n_nodup_log.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Feature test macro.

GNU source

Definition at line 10 of file n_nodup_log.c.

◆ _GNU_SOURCE_WAS_NOT_DEFINED

#define _GNU_SOURCE_WAS_NOT_DEFINED

flag to detect if gnu source was set from our source file

Definition at line 12 of file n_nodup_log.c.

Function Documentation

◆ check_n_log_dup()

check_n_log_dup ( const char *  log,
const char *  file,
const char *  func,
int  line 
)

check if a log was already done or not at the given line, func, file

Parameters
logthe line of log
filethe file containing the log
functhe name of calling func
linethe line of the log
Returns
0 if not existing 1 if existing with the same value , 2 if key exist and value is different

Definition at line 137 of file n_nodup_log.c.

References __n_assert, _n_nodup_table, Free, get_nodup_key(), and ht_get_node().

Referenced by _n_nodup_log().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_n_log_dup_indexed()

check_n_log_dup_indexed ( const char *  log,
const char *  file,
const char *  func,
int  line,
const char *  prefix 
)

check if a log was already done or not at the given line, func, file

Parameters
logthe line of log
filethe file containing the log
functhe name of calling func
linethe line of the log
prefixprefix to subgroup logs
Returns
0 if not existing 1 if existing with the same value , 2 if key exist and value is different

Definition at line 180 of file n_nodup_log.c.

References __n_assert, _n_nodup_table, Free, get_nodup_indexed_key(), and ht_get_node().

Referenced by _n_nodup_log_indexed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_nodup_indexed_key()

char * get_nodup_indexed_key ( const char *  file,
const char *  func,
const char *  prefix,
int  line 
)
static

internal, get a key for an indexed log entry

Parameters
filelog source file
funclog source
linelog source
prefixprefix for log entry
Returns
The key for the the log entry

Definition at line 114 of file n_nodup_log.c.

References __n_assert, Free, and nstrprintf.

Referenced by _n_nodup_log_indexed(), and check_n_log_dup_indexed().

+ Here is the caller graph for this function:

◆ get_nodup_key()

char * get_nodup_key ( const char *  file,
const char *  func,
int  line 
)
static

internal, get a key for a log entry

Parameters
filelog source file
funclog source
linelog source
Returns
The key for the the log entry

Definition at line 93 of file n_nodup_log.c.

References __n_assert, Free, and nstrprintf.

Referenced by _n_nodup_log(), and check_n_log_dup().

+ Here is the caller graph for this function:

Variable Documentation

◆ _n_nodup_table

HASH_TABLE* _n_nodup_table = NULL
static