|
Packit |
8480eb |
/* ----------------------------------------------------------------------- *
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* log.c - applcation logging declarations.
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* Copyright 2004 Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
|
|
Packit |
8480eb |
* - All Rights Reserved
|
|
Packit |
8480eb |
* Copyright 2005 Ian Kent <raven@themaw.net> - All Rights Reserved
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
8480eb |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
8480eb |
* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
|
|
Packit |
8480eb |
* USA; either version 2 of the License, or (at your option) any later
|
|
Packit |
8480eb |
* version; incorporated herein by reference.
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* ----------------------------------------------------------------------- */
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#ifndef LOG_H
|
|
Packit |
8480eb |
#define LOG_H
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
/* Define logging functions */
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define LOGOPT_NONE 0x0000
|
|
Packit |
8480eb |
#define LOGOPT_ERROR 0x0000
|
|
Packit |
8480eb |
#define LOGOPT_DEBUG 0x0001
|
|
Packit |
8480eb |
#define LOGOPT_VERBOSE 0x0002
|
|
Packit |
8480eb |
#define LOGOPT_ANY (LOGOPT_DEBUG | LOGOPT_VERBOSE)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
struct autofs_point;
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
extern void set_log_norm(void);
|
|
Packit |
8480eb |
extern void set_log_verbose(void);
|
|
Packit |
8480eb |
extern void set_log_debug(void);
|
|
Packit |
8480eb |
extern void set_log_norm_ap(struct autofs_point *ap);
|
|
Packit |
8480eb |
extern void set_log_verbose_ap(struct autofs_point *ap);
|
|
Packit |
8480eb |
extern void set_log_debug_ap(struct autofs_point *ap);
|
|
Packit |
8480eb |
extern void set_mnt_logging(unsigned global_logopt);
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
extern void open_log(void);
|
|
Packit |
8480eb |
extern void log_to_stderr(void);
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
extern void log_info(unsigned int, const char* msg, ...);
|
|
Packit |
8480eb |
extern void log_notice(unsigned int, const char* msg, ...);
|
|
Packit |
8480eb |
extern void log_warn(unsigned int, const char* msg, ...);
|
|
Packit |
8480eb |
extern void log_error(unsigned, const char* msg, ...);
|
|
Packit |
8480eb |
extern void log_crit(unsigned, const char* msg, ...);
|
|
Packit |
8480eb |
extern void log_debug(unsigned int, const char* msg, ...);
|
|
Packit |
8480eb |
extern void logmsg(const char* msg, ...);
|
|
Packit |
8480eb |
|
|
Packit Service |
888ac8 |
extern pid_t log_pidinfo(struct autofs_point *ap, pid_t pid, char *label);
|
|
Packit Service |
888ac8 |
|
|
Packit |
8480eb |
#define debug(opt, msg, args...) \
|
|
Packit |
8480eb |
do { log_debug(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define info(opt, msg, args...) \
|
|
Packit |
8480eb |
do { log_info(opt, msg, ##args); } while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define notice(opt, msg, args...) \
|
|
Packit |
8480eb |
do { log_notice(opt, msg, ##args); } while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define warn(opt, msg, args...) \
|
|
Packit |
8480eb |
do { log_warn(opt, msg, ##args); } while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define error(opt, msg, args...) \
|
|
Packit |
8480eb |
do { log_error(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define crit(opt, msg, args...) \
|
|
Packit |
8480eb |
do { log_crit(opt, "%s: " msg, __FUNCTION__, ##args); } while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define logerr(msg, args...) \
|
|
Packit |
8480eb |
do { logmsg("%s:%d: " msg, __FUNCTION__, __LINE__, ##args); } while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define fatal(status) \
|
|
Packit |
8480eb |
do { \
|
|
Packit |
8480eb |
if (status == EDEADLK) { \
|
|
Packit |
8480eb |
logmsg("deadlock detected " \
|
|
Packit |
8480eb |
"at line %d in %s, dumping core.", \
|
|
Packit |
8480eb |
__LINE__, __FILE__); \
|
|
Packit |
8480eb |
dump_core(); \
|
|
Packit |
8480eb |
} \
|
|
Packit |
8480eb |
logmsg("unexpected pthreads error: %d at %d " \
|
|
Packit |
8480eb |
"in %s", status, __LINE__, __FILE__); \
|
|
Packit |
8480eb |
abort(); \
|
|
Packit |
8480eb |
} while(0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#ifndef NDEBUG
|
|
Packit |
8480eb |
#define assert(x) \
|
|
Packit |
8480eb |
do { \
|
|
Packit |
8480eb |
if (!(x)) { \
|
|
Packit |
8480eb |
logmsg(__FILE__ \
|
|
Packit |
8480eb |
":%d: assertion failed: " #x, __LINE__); \
|
|
Packit |
8480eb |
} \
|
|
Packit |
8480eb |
} while(0)
|
|
Packit |
8480eb |
#else
|
|
Packit |
8480eb |
#define assert(x) do { } while(0)
|
|
Packit |
8480eb |
#endif
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#endif
|
|
Packit |
8480eb |
|