KPN IoT / senml

Fork of kpn_senml by KPN IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers senml_logging.h Source File

senml_logging.h

00001 /*  _  __  ____    _   _ 
00002  * | |/ / |  _ \  | \ | |
00003  * | ' /  | |_) | |  \| |
00004  * | . \  |  __/  | |\  |
00005  * |_|\_\ |_|     |_| \_|
00006  * 
00007  * (c) 2018 KPN
00008  * License: MIT License.
00009  * Author: Jan Bogaerts
00010  * 
00011  * logging
00012  */
00013 
00014 #ifndef SENMLLOGGING
00015 #define SENMLLOGGING
00016 
00017 #ifdef __MBED__
00018     #include "mbed.h"
00019     #include "sstream"
00020 #else
00021     #include <stream.h>
00022 #endif
00023 
00024 //contains a referenc to the global logger object assigned to the module
00025 extern Stream* _senml_logger;
00026 
00027 /**
00028  * Assign a stream to the library that can be used to write log information to.
00029  * @param logger a stream object that will be used for logging. 
00030  * @returns none
00031  */
00032 void senMLSetLogger(Stream* logger);
00033 
00034 #ifndef log_debug
00035     #ifdef __MBED__
00036         #define log_debug(...)  if(_senml_logger) {_senml_logger->printf(__VA_ARGS__); _senml_logger->printf("\n\r"); }
00037     #else    
00038         #define log_debug(...)  if(_senml_logger) _senml_logger->println(__VA_ARGS__)
00039     #endif
00040 #endif
00041 
00042 
00043 #endif // SENMLLOGGING
00044 
00045 
00046 
00047 
00048 
00049 
00050