First incarnation of the logging code

This commit is contained in:
2016-02-03 10:43:36 +01:00
parent 95988f331c
commit b1cda3f579
4 changed files with 548 additions and 1 deletions

60
logv2.h Normal file
View File

@ -0,0 +1,60 @@
/*
This is a reimplementation of SICS logging. The aim is to
merge all the different logs within SICS to the new logging
system
COPYRIGHT: see file COPYRIGHT
Mark Koennecke, February 2016
*/
#ifndef __LOGV2
#define __LOGV2
#include <stdarg.h>
#define FATAL 1
#define ERROR 2
#define WARN 3
#define INFO 4
#define VERBOSE 5
#define DEBUG 6
#define INVALID 7 /* internal olny, do not use, means invalid severity passed */
/* write a log message
* \param severity The message severity. Must be one of the defines given above
* \param subsystem The subsystem reporting the log messages
* \param format The format string for the message
* \param ... The data to format
*/
void Log(unsigned int severity, const char *subsystem,const char *format,...);
/* The callback functio which is called by the logging system on log events
* \param severity The message severity
* \param timeStamp The time stamp of the log message
* \param subsystem The subsystem of the log message
* \param message The log message
* \param userData A pointer to a user define ddata structure passed through
* transparantly from RegisterLogCallback
*/
/*
At this time LogCallback do not do any filtering. Thus, they see every message.
The idea is that suitable filtering functions ought to be implemented as helper
functions once the exact usage of the log \callbacks becomes clearer.
*/
typedef void (*LogCallback)(unsigned int severity, const char *timeStamp,
const char *subsystem,
const char *message, void *userData);
/* register a LogCallback
* \param func The function to call whena suitable log message has been found
* \param userData A pointer to user defined data which is passed through to the
* callback function. The log system does not free that pointer; this is up to the caller
* \return An callback ID which can be used for RemoveLogCallback
*/
void RegisterLogCallback(LogCallback func, void *userData);
void RemoveLogCallback(LogCallback func);
#endif