1 /*************************************************************************
3 * Copyright 2020 highstreet technologies GmbH and others
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
23 #define LOG_COLOR_RESET "\033[0m"
24 #define LOG_COLOR_RED "\033[0;31m"
25 #define LOG_COLOR_BOLD_RED "\033[1;31m"
26 #define LOG_COLOR_GREEN "\033[0;32m"
27 #define LOG_COLOR_BOLD_GREEN "\033[1;32m"
28 #define LOG_COLOR_YELLOW "\033[0;33m"
29 #define LOG_COLOR_BOLD_YELLOW "\033[01;33m"
30 #define LOG_COLOR_BLUE "\033[0;34m"
31 #define LOG_COLOR_BOLD_BLUE "\033[1;34m"
32 #define LOG_COLOR_MAGENTA "\033[0;35m"
33 #define LOG_COLOR_BOLD_MAGENTA "\033[1;35m"
34 #define LOG_COLOR_CYAN "\033[0;36m"
35 #define LOG_COLOR_BOLD_CYAN "\033[1;36m"
37 #define NTS_ERR_OK (0)
38 #define NTS_ERR_FAILED (-1)
40 void log_init(const char *logfilename);
41 void log_redirect_stderr(const char *stderrfilename);
42 #pragma GCC diagnostic push
43 #pragma GCC diagnostic ignored "-Wvariadic-macros"
44 #define log_add_verbose(verbose_level, format, args...) log__message(__FILE__, (uint32_t)__LINE__, verbose_level, format, ## args);
45 #define log_add(verbose_level, format, args...) log__message(__FILE__, (uint32_t)__LINE__, -verbose_level, format, ## args);
46 #define log_error(format, args...) log__message(__FILE__, (uint32_t)__LINE__, 0, format, ## args);
47 #pragma GCC diagnostic pop
50 //masked functions (use macros defined above)
51 void log__message(char const * const fname, uint32_t location, int verbose_level, const char *format, ...);