1 /*******************************************************************
2 uLan Utilities Library - C library of basic reusable constructions
4 ul_logbase.h - base of standard logging facility
6 (C) Copyright 2005 by Pavel Pisa - Originator
8 The uLan utilities library can be used, copied and modified under
10 - GPL - GNU General Public License
11 - LGPL - GNU Lesser General Public License
12 - MPL - Mozilla Public License
13 - and other licenses added by project originators
14 Code can be modified and re-distributed under any combination
15 of the above listed licenses. If contributor does not agree with
16 some of the licenses, he/she can delete appropriate line.
17 Warning, if you delete all lines, you are not allowed to
18 distribute source code and/or binaries utilizing code.
20 See files COPYING and README for details.
22 *******************************************************************/
28 #include "ul_utdefs.h"
34 #define UL_LOGL_MASK (0xff)
35 #define UL_LOGL_CONT (0x1000)
37 #define UL_LOGL_FATAL 1
42 #define UL_LOGL_TRASH 6
49 * struct ul_log_domain - Loggomg domain structure
50 * @level: maximal enabled logging level for domain
51 * @name: logging domain name
52 * @flags: logging domain flags
54 typedef struct ul_log_domain {
60 typedef void (ul_log_fnc_t)(ul_log_domain_t *domain, int level,
61 const char *format, va_list ap) UL_ATTR_REENTRANT;
63 void ul_log_redir(ul_log_fnc_t *log_fnc, int add_flags);
65 int ul_log_check_default_output(void);
67 void ul_vlog1(ul_log_domain_t *domain, int level,
68 const char *format, va_list ap);
70 void ul_log1(ul_log_domain_t *domain, int level,
71 const char *format, ...) UL_ATTR_PRINTF (3, 4);
73 #ifdef UL_LOG_NOINLINE
75 int ul_log_cond(ul_log_domain_t *domain, int level);
77 void ul_vlog(ul_log_domain_t *domain, int level,
78 const char *format, va_list ap);
80 void ul_log(ul_log_domain_t *domain, int level,
81 const char *format, ...) UL_ATTR_PRINTF (3, 4);
83 #else /*UL_LOG_NOINLINE*/
86 int ul_log_cond(ul_log_domain_t *domain, int level)
88 if(!domain || ((level&UL_LOGL_MASK) > UL_LOGL_MAX))
90 return (level&UL_LOGL_MASK) <= domain->level;
94 void ul_vlog(ul_log_domain_t *domain, int level,
95 const char *format, va_list ap)
97 if(!ul_log_cond(domain,level))
99 ul_vlog1(domain, level, format, ap);
103 void ul_log(ul_log_domain_t *domain, int level,
104 const char *format, ...) UL_ATTR_PRINTF (3, 4);
107 void ul_log(ul_log_domain_t *domain, int level,
108 const char *format, ...)
112 if(!ul_log_cond(domain,level))
114 va_start (ap, format);
115 ul_vlog1(domain, level, format, ap);
119 #endif /*UL_LOG_NOINLINE*/
125 #endif /*_UL_LOGBASE_H*/