Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_log.h File Reference

Generic log system. More...

#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <pthread.h>
#include "n_common.h"
#include <stdarg.h>
Include dependency graph for n_log.h:

Go to the source code of this file.

Data Structures

struct  TS_LOG
 ThreadSafe LOGging structure. More...

Macros

#define LOG_ALERT   1
 action must be taken immediately
#define LOG_CRIT   2
 critical conditions
#define LOG_DEBUG   7
 debug-level messages
#define LOG_EMERG   0
 system is unusable
#define LOG_ERR   3
 error conditions
#define LOG_FILE   -3
 internal, logging to file
#define LOG_INFO   6
 informational
#define LOG_NOTICE   5
 normal but significant condition
#define LOG_NULL   -1
 no log output
#define LOG_STDERR   -4
 internal, default LOG_TYPE
#define LOG_SYSJRNL   100
 to sysjrnl
#define LOG_WARNING   4
 warning conditions
#define n_log(__LEVEL__, ...)
 Logging function wrapper to get line and func.
#define N_PRINTF_FORMAT(fmt, args)
 declare a function printf-like; nothing on a compiler without attributes

Functions

void _n_log (int level, const char *file, const char *func, int line, const char *format,...)
 Full log function.
int close_safe_logging (TS_LOG *log)
 close a thread-safe logging file
void close_sysjrnl (void)
 close syslog / free name for event log
FILE * get_log_file (void)
 get the log file name if any
int get_log_level (void)
 Return the global log level.
int open_safe_logging (TS_LOG **log, char *pathname, char *opt)
 Open a thread-safe logging file.
char * open_sysjrnl (const char *identity)
 Open a syslog / set name for event log.
int set_log_file (char *file)
 set a file as standard log output
int set_log_file_fd (FILE *fd)
 set an already open stream (stdout, stderr, a caller's FILE) as standard log output, never closed by the library
void set_log_level (const int log_level)
 Set global log level.
int write_safe_log (TS_LOG *log, char *pat,...)
 write to a thread-safe logging file

Detailed Description

Generic log system.

Author
Castagnier Mickael
Date
2013-04-15

Definition in file n_log.h.