Update date in copyrights
[src/app-framework-main.git] / src / verbose.h
1 /*
2  Copyright (C) 2016-2019 "IoT.bzh"
3
4  author: José Bollo <jose.bollo@iot.bzh>
5
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
9
10      http://www.apache.org/licenses/LICENSE-2.0
11
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.
17 */
18
19 #pragma once
20
21 #include <stdarg.h>
22
23 extern int verbosity;
24
25 extern void verbose_set_name(const char *name, int authority);
26 extern void verbose(int level, const char *file, int line, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
27 extern void vverbose(int level, const char *file, int line, const char *fmt, va_list args);
28
29 # define ERROR(...)   do{if(verbosity>=0)verbose(3,__FILE__,__LINE__,__VA_ARGS__);}while(0)
30 # define WARNING(...) do{if(verbosity>=1)verbose(4,__FILE__,__LINE__,__VA_ARGS__);}while(0)
31 # define NOTICE(...)  do{if(verbosity>=1)verbose(5,__FILE__,__LINE__,__VA_ARGS__);}while(0)
32 # define INFO(...)    do{if(verbosity>=2)verbose(6,__FILE__,__LINE__,__VA_ARGS__);}while(0)
33 # define DEBUG(...)   do{if(verbosity>=3)verbose(7,__FILE__,__LINE__,__VA_ARGS__);}while(0)
34 # define LOGUSER(app) verbose_set_name(app,0)
35 # define LOGAUTH(app) verbose_set_name(app,1)
36