Nilorea Library

- Main Page
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Macros Groups
Data Structures | Macros | Typedefs | Functions
LOGGING: logging to console, to file, to syslog underx

## Data Structures

struct | TS_LOG

## Macros

#define | NOLOG -1
#define | SYSJRNL -2
#define | LOG_EMERG 0
#define | LOG_ALERT 1
#define | LOG_CRIT 2
#define | LOG_ERR 3
#define | LOG_WARNING 4
#define | LOG_NOTICE 5
#define | LOG_INFO 6
#define | LOG_DEBUG 7
#define | n_log(__LEVEL__,...)

## Typedefs

typedef struct TS_LOG | TS_LOG

## Functions

void | set_log_level (const int log_level)
| Set the global log level value ( static int LOG_LEVEL ) More...
int | get_log_level ()
| Get the global log level value. More...
int | set_log_file (char *file)
| Set the logging to a file instead of stderr. More...
FILE * | get_log_file ()
| return the current log_file More...
void | _n_log (int level, const char *file, const char *func, int line, const char *format,...)
| Logging function. log( level , const char *format , ... ) is a macro around _log. More...
int | open_safe_logging (TS_LOG **log, char *pathname, char *opt)
| Open a thread-safe logging file. More...
int | write_safe_log (TS_LOG *log, char *pat,...)
| write to a thread-safe logging file More...
int | close_safe_logging (TS_LOG *log)
| close a thread-safe logging file More...

## Detailed Description

## Macro Definition Documentation

#define LOG_ALERT 1

action must be taken immediately

Definition at line 53 of file n_log.h.

#define LOG_CRIT 2

critical conditions

Definition at line 55 of file n_log.h.

#define LOG_DEBUG 7

debug-level messages

Definition at line 65 of file n_log.h.

#define LOG_EMERG 0

system is unusable

Definition at line 51 of file n_log.h.

#define LOG_ERR 3

error conditions

Definition at line 57 of file n_log.h.

#define LOG_INFO 6

informational

Definition at line 63 of file n_log.h.

#define LOG_NOTICE 5

normal but significant condition

Definition at line 61 of file n_log.h.

#define LOG_WARNING 4

warning conditions

Definition at line 59 of file n_log.h.

#define n_log | ( |  | __LEVEL__,
|  |  | ...
| ) |  |

Value:
do \
{ \
_n_log( __LEVEL__ , __FILE__ , __func__ , __LINE__ , __VA_ARGS__ ); \
}while( 0 )

Logging function wrapper to get line and func

Definition at line 72 of file n_log.h.

#define NOLOG -1

no log output

Definition at line 29 of file n_log.h.

#define SYSJRNL -2

syslog journal output if available (*nix only)

Definition at line 32 of file n_log.h.

## Typedef Documentation

typedef struct TS_LOG TS_LOG

ThreadSafe LOGging structure

## Function Documentation

void _n_log | ( | int | level,
|  | const char * | file,
|  | const char * | func,
|  | int | line,
|  | const char * | format,
|  |  | ...
| ) |  |

Logging function. log( level , const char *format , ... ) is a macro around _log.

Parameters

  level | Logging level
  file | File containing the emmited log
  func | Function emmiting the log
  line | Line of the log
  format | Format and string of the log, printf style

Definition at line 80 of file n_log.c.

Here is the call graph for this function:

close_safe_logging | ( | TS_LOG * | log | ) |

close a thread-safe logging file

Parameters

  log | A TS_LOG handler

Returns
  TRUE on success, FALSE on error

Definition at line 247 of file n_log.c.

FILE * get_log_file | ( |  | ) |

return the current log_file

Returns
  a valid FILE handle or NULL

Definition at line 65 of file n_log.c.

int get_log_level | ( |  | ) |

Get the global log level value.

Returns
  static int LOG_LEVEL

Definition at line 31 of file n_log.c.

Here is the caller graph for this function:

open_safe_logging | ( | TS_LOG ** | log,
|  | char * | pathname,
|  | char * | opt
| ) |  |

Open a thread-safe logging file.

Parameters

  log | A TS_LOG handler
  pathname | The file path (if any) and name
  opt | Options for opening (please never forget to use "w")

Returns
  TRUE on success , FALSE on error , -1000 if already open

Definition at line 178 of file n_log.c.

int set_log_file | ( | char * | file | ) |

Set the logging to a file instead of stderr.

Returns
  TRUE or FALSE

Definition at line 42 of file n_log.c.

void set_log_level | ( | const int | log_level | ) |

Set the global log level value ( static int LOG_LEVEL )

Parameters

  log_level | Log level value. Supported: JRNLONLY,NOLOG,LOG_NOTICE/INFO/ERR/DEBUG

Definition at line 20 of file n_log.c.

Here is the caller graph for this function:

write_safe_log | ( | TS_LOG * | log,
|  | char * | pat,
|  |  | ...
| ) |  |

write to a thread-safe logging file

Parameters

  log | A TS_LOG handler
  pat | Pattern for writting (i.e "%d %d %s")

Returns
  TRUE on success, FALSE on error

Definition at line 215 of file n_log.c.