esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
log.hpp
Go to the documentation of this file.
1#ifndef NDNPH_CORE_LOG_HPP
2#define NDNPH_CORE_LOG_HPP
3
4#include "common.hpp"
5#ifdef ARDUINO
6#include "../port/clock/port.hpp"
7#else
8#include "../port/unixtime/port.hpp"
9#endif
10
11#ifndef NDNPH_LOG_PRINTF
12#ifdef ARDUINO
13#define NDNPH_LOG_PRINTF(...) Serial.printf(__VA_ARGS__)
14#else
15#ifndef NDNPH_LOG_FILE
16#define NDNPH_LOG_FILE stderr
17#endif
18#define NDNPH_LOG_PRINTF(...) fprintf((NDNPH_LOG_FILE), ##__VA_ARGS__)
19#endif
20#endif // NDNPH_LOG_PRINTF
21
22#ifndef NDNPH_LOG_NOWVAR
23#ifdef ARDUINO
24#define NDNPH_LOG_NOWVAR millis()
25#else
26#define NDNPH_LOG_NOWVAR (ndnph::port::UnixTime::now() / 1000)
27#endif
28#endif // NDNPH_LOG_NOWVAR
29
30#ifndef NDNPH_LOG_NOWFMT
31#ifdef ARDUINO
32#define NDNPH_LOG_NOWFMT "%lu"
33#else
34#define NDNPH_LOG_NOWFMT "%" PRIu64
35#endif
36#endif // NDNPH_LOG_NOWFMT
37
43#define NDNPH_LOG_MSG(category, fmt, ...) \
44 NDNPH_LOG_PRINTF(NDNPH_LOG_NOWFMT " [" category "] " fmt, NDNPH_LOG_NOWVAR, ##__VA_ARGS__)
45
50#define NDNPH_LOG_LINE(category, fmt, ...) NDNPH_LOG_MSG(category, fmt "\n", ##__VA_ARGS__)
51
52#endif // NDNPH_CORE_LOG_HPP