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"
30 #define UL_LOGL_MASK (0xff)
31 #define UL_LOGL_CONT (0x1000)
33 #define UL_LOGL_FATAL 1
38 #define UL_LOGL_TRASH 6
45 * struct ul_log_domain - Loggomg domain structure
46 * @level: maximal enabled logging level for domain
47 * @name: logging domain name
48 * @flags: logging domain flags
50 typedef struct ul_log_domain {
56 typedef void (ul_log_fnc_t)(ul_log_domain_t *domain, int level,
57 const char *format, va_list ap);
59 void ul_log_redir(ul_log_fnc_t *log_fnc, int add_flags);
61 void ul_vlog1(ul_log_domain_t *domain, int level,
62 const char *format, va_list ap);
64 void ul_log1(ul_log_domain_t *domain, int level,
65 const char *format, ...) UL_ATTR_PRINTF (3, 4);
67 #ifdef UL_LOG_NOINLINE
69 int ul_log_cond(ul_log_domain_t *domain, int level);
71 void ul_vlog(ul_log_domain_t *domain, int level,
72 const char *format, va_list ap);
74 void ul_log(ul_log_domain_t *domain, int level,
75 const char *format, ...) UL_ATTR_PRINTF (3, 4);
77 #else /*UL_LOG_NOINLINE*/
80 int ul_log_cond(ul_log_domain_t *domain, int level)
82 if(!domain || (level > UL_LOGL_MAX))
84 return level <= domain->level;
88 void ul_vlog(ul_log_domain_t *domain, int level,
89 const char *format, va_list ap)
91 if(!ul_log_cond(domain,level))
93 ul_vlog1(domain, level, format, ap);
97 void ul_log(ul_log_domain_t *domain, int level,
98 const char *format, ...) UL_ATTR_PRINTF (3, 4);
101 void ul_log(ul_log_domain_t *domain, int level,
102 const char *format, ...)
106 if(!ul_log_cond(domain,level))
108 va_start (ap, format);
109 ul_vlog1(domain, level, format, ap);
113 #endif /*UL_LOG_NOINLINE*/
115 #endif /*_UL_LOGBASE_H*/