2 Copyright (C) 2016 "IoT.bzh"
4 author: José Bollo <jose.bollo@iot.bzh>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
21 #if !defined(VERBOSE_WITH_SYSLOG)
24 extern void verbose(int level, const char *file, int line, const char *fmt, ...);
26 # define ERROR(...) do{if(verbosity>=0)verbose(3,__FILE__,__LINE__,__VA_ARGS__);}while(0)
27 # define WARNING(...) do{if(verbosity>=1)verbose(4,__FILE__,__LINE__,__VA_ARGS__);}while(0)
28 # define NOTICE(...) do{if(verbosity>=1)verbose(5,__FILE__,__LINE__,__VA_ARGS__);}while(0)
29 # define INFO(...) do{if(verbosity>=2)verbose(6,__FILE__,__LINE__,__VA_ARGS__);}while(0)
30 # define DEBUG(...) do{if(verbosity>=3)verbose(7,__FILE__,__LINE__,__VA_ARGS__);}while(0)
31 # define LOGUSER(app) NOTICE("Starting user application %s",app)
32 # define LOGAUTH(app) NOTICE("Starting auth application %s",app)
34 #else /* VERBOSE_WITH_SYSLOG is defined */
38 # define LOGUSER(app) openlog(app,LOG_PERROR,LOG_USER)
39 # define LOGAUTH(app) openlog(app,LOG_PERROR,LOG_AUTH)
44 # define ERROR(...) syslog(LOG_ERR,__VA_ARGS__)
45 # define WARNING(...) do{if(verbosity)syslog(LOG_WARNING,__VA_ARGS__);}while(0)
46 # define NOTICE(...) do{if(verbosity)syslog(LOG_NOTICE,__VA_ARGS__);}while(0)
47 # define INFO(...) do{if(verbosity>1)syslog(LOG_INFO,__VA_ARGS__);}while(0)
48 # define DEBUG(...) do{if(verbosity>2)syslog(LOG_DEBUG,__VA_ARGS__);}while(0)
52 extern void verbose_error(const char *file, int line);
53 # define ERROR(...) verbose_error(__FILE__,__LINE__)
54 # define WARNING(...) do{/*nothing*/}while(0)
55 # define NOTICE(...) do{/*nothing*/}while(0)
56 # define INFO(...) do{/*nothing*/}while(0)
57 # define DEBUG(...) do{/*nothing*/}while(0)