-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
98 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
PSEUDOMODULES += defaulttransceiver | ||
PSEUDOMODULES += transport_layer | ||
PSEUDOMODULES += pktqueue | ||
PSEUDOMODULES += log_printfnoformat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2015 Kaspar Schleiser | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @addtogroup core_util | ||
* @{ | ||
* | ||
* @file log.h | ||
* @brief System logging header | ||
* | ||
* @author Kaspar Schleiser <kaspar@schleiser.de> | ||
*/ | ||
|
||
#ifndef __LOG_H | ||
#define __LOG_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
enum { | ||
LOG_NONE, | ||
LOG_ERROR, | ||
LOG_WARNING, | ||
LOG_INFO, | ||
LOG_DEBUG, | ||
LOG_ALL | ||
}; | ||
|
||
#ifndef LOG_LEVEL | ||
#define LOG_LEVEL LOG_ALL | ||
#endif | ||
|
||
/** | ||
* @brief Log message if level <= LOG_LEVEL | ||
* | ||
* ... doc to come ... | ||
* | ||
* @{ | ||
*/ | ||
|
||
#define LOG(level, ...) if (level <= LOG_LEVEL) _log(level, __VA_ARGS__) | ||
|
||
/** @} */ | ||
|
||
#ifdef HAVE_LOG_MODULE | ||
#include "log_module.h" | ||
#else | ||
|
||
#include <stdio.h> | ||
|
||
#define _log(level, ...) printf(__VA_ARGS__) | ||
|
||
#define log_error(...) LOG(LOG_ERROR, __VA_ARGS__) | ||
#define log_warning(...) LOG(LOG_WARNING, __VA_ARGS__) | ||
#define log_info(...) LOG(LOG_INFO, __VA_ARGS__) | ||
#define log_debug(...) LOG(LOG_DEBUG, __VA_ARGS__) | ||
|
||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __LOG_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef __LOG_FORMAT_H | ||
#define __LOG_FORMAT_H | ||
|
||
#include <stdio.h> | ||
|
||
static void _log(unsigned level, const char *format, ...) { | ||
(void)level; | ||
puts(format); | ||
} | ||
|
||
#define log_error(...) LOG(LOG_ERROR, "E: " __VA_ARGS__) | ||
#define log_warning(...) LOG(LOG_WARNING, "W: " __VA_ARGS__) | ||
#define log_info(...) LOG(LOG_INFO, "I: " __VA_ARGS__) | ||
#define log_debug(...) LOG(LOG_DEBUG, "D: " __VA_ARGS__) | ||
|
||
#endif /* __LOG_FORMAT_H */ |
This file was deleted.
Oops, something went wrong.