lsyncd/core/log.h

60 lines
1.6 KiB
C
Raw Normal View History

2018-03-23 08:34:33 +00:00
/*
2018-03-30 13:15:49 +00:00
| log.h from Lsyncd -- the Live (Mirror) Syncing Demon
2018-03-27 06:54:14 +00:00
|
2018-03-30 13:15:49 +00:00
| Logging.
2018-03-23 08:34:33 +00:00
|
| License: GPLv2 (see COPYING) or any later version
| Authors: Axel Kittenberger <axkibe@gmail.com>
*/
#ifndef LSYNCD_LOG_H
#define LSYNCD_LOG_H
2018-04-13 20:55:04 +00:00
// Logging configuration
// This used to be general setting, but with the Lsyncd 3 razor, only logging
// stuff is left, likely to be reworked
extern struct settings {
char * log_file; // If not NULL Lsyncd logs into this file.
bool log_syslog; // If true Lsyncd sends log messages to syslog
char * log_ident; // If not NULL the syslog identity (otherwise "Lsyncd")
int log_facility; // The syslog facility
int log_level; // -1 logs everything, 0 normal mode, LOG_ERROR errors only.
} settings;
2018-04-03 06:54:07 +00:00
// Returns a logging facility number by name.
extern int log_getFacility( lua_State * L, char const * fname);
2018-03-23 08:34:33 +00:00
// Adds a logging category
2018-04-03 06:54:07 +00:00
extern bool add_logcat( char const * name, int priority );
2018-03-23 08:34:33 +00:00
// Returns the positive priority if name is configured to be logged, or -1
2018-04-03 06:54:07 +00:00
extern int check_logcat( char const * name );
2018-03-23 08:34:33 +00:00
// logs a string
#define logstring(cat, message) \
{int p; if ((p = check_logcat(cat)) <= settings.log_level) \
{logstring0(p, cat, message);}}
2018-04-03 06:54:07 +00:00
extern void logstring0( int priority, char const * cat, char const * message );
2018-03-23 08:34:33 +00:00
// logs a formated string
#define printlogf(L, cat, ...) \
{int p; if ((p = check_logcat(cat)) <= settings.log_level) \
{printlogf0(L, p, cat, __VA_ARGS__);}}
extern void
printlogf0(
lua_State *L,
int priority,
2018-04-03 06:54:07 +00:00
char const * cat,
char const * fmt,
...
2018-03-23 08:34:33 +00:00
) __attribute__ ( ( format( printf, 4, 5 ) ) );
// Frees logging stuff
extern void log_free( );
2018-04-03 06:59:04 +00:00
extern int l_log( lua_State * L );
2018-03-23 08:34:33 +00:00
#endif