Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
Typedefs | Enumerations | Functions
logger.h File Reference

Logger for the hicn-light forwarder. More...

#include <sys/time.h>
#include <parc/algol/parc_Buffer.h>
#include <parc/algol/parc_Clock.h>
#include <parc/logging/parc_LogLevel.h>
#include <parc/logging/parc_LogReporter.h>
#include <stdarg.h>
Include dependency graph for logger.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct logger Logger
 

Enumerations

enum  LoggerFacility {
  LoggerFacility_Config, LoggerFacility_Core, LoggerFacility_IO, LoggerFacility_Processor,
  LoggerFacility_Message, LoggerFacility_Strategy, LoggerFacility_END
}
 

Functions

const char * logger_FacilityString (LoggerFacility facility)
 
const char * logger_LevelString (PARCLogLevel level)
 
Logger * logger_Create (PARCLogReporter *reporter, const PARCClock *clock)
 
void logger_Release (Logger **loggerPtr)
 
Logger * logger_Acquire (const Logger *logger)
 
void logger_SetLogLevel (Logger *logger, LoggerFacility facility, PARCLogLevel minimumLevel)
 
bool logger_IsLoggable (const Logger *logger, LoggerFacility facility, PARCLogLevel level)
 
void logger_Log (Logger *logger, LoggerFacility facility, PARCLogLevel level, const char *module, const char *format,...)
 
void logger_SetReporter (Logger *logger, PARCLogReporter *reporter)
 
void logger_SetClock (Logger *logger, PARCClock *clock)
 

Detailed Description

Logger for the hicn-light forwarder.

A facility based logger to allow selective logging from different parts of hicn-light

Enumeration Type Documentation

◆ LoggerFacility

CONFIG faciilty concerns anything in the /config directory CORE concerns anything in the /core directory IO concerns anything in the /io directory (listeners, connectors, tcp, ethernet, etc.) PROCESSOR concerns FIB, PIT, CS MESSAGE concerns message events, like parsing

Function Documentation

◆ logger_Acquire()

Logger* logger_Acquire ( const Logger *  logger)

Acquire logger

◆ logger_Create()

Logger* logger_Create ( PARCLogReporter *  reporter,
const PARCClock *  clock 
)

Create a logger that uses a given writer and clock

<#Paragraphs Of Explanation#>

Parameters
[in]writerThe output writer
[in]clockThe clock to use for log messages
Return values
non-nullAn allocated logger
nullAn error

◆ logger_FacilityString()

const char* logger_FacilityString ( LoggerFacility  facility)

Returns a string representation of a facility

Do not free the returned value.

Parameters
[in]facilityThe facility to change to a string
Return values
stringA string representation of the facility

◆ logger_IsLoggable()

bool logger_IsLoggable ( const Logger *  logger,
LoggerFacility  facility,
PARCLogLevel  level 
)

Tests if the log level would be logged

If the facility would log the given level, returns true. May be used as a guard around expensive logging functions.

Parameters
[in]loggerAn allocated logger
[in]facilityThe facility to test
[in]Thelevel to test
Return values
trueThe given facility would log the given level
falseA message of the given level would not be logged

◆ logger_LevelString()

const char* logger_LevelString ( PARCLogLevel  level)

Returns a string representation of a log level

Do not free the returned value.

Parameters
[in]levelThe level to change to a string
Return values
stringA string representation of the level

◆ logger_Log()

void logger_Log ( Logger *  logger,
LoggerFacility  facility,
PARCLogLevel  level,
const char *  module,
const char *  format,
  ... 
)

Log a message

The message will only be logged if it is loggable (logger_IsLoggable returns true).

Parameters
[in]loggerAn allocated Logger
[in]facilityThe facility to log under
[in]levelThe log level of the message
[in]moduleThe specific module logging the message
[in]formatThe message with varargs

◆ logger_Release()

void logger_Release ( Logger **  loggerPtr)

Release logger

◆ logger_SetClock()

void logger_SetClock ( Logger *  logger,
PARCClock *  clock 
)

Set a new clock to use with the logger

The logger will start getting the time (logged as the messageid) from the specified clock

Parameters
[in]loggerAn allocated Logger
[in]clockAn allocated PARCClock

◆ logger_SetLogLevel()

void logger_SetLogLevel ( Logger *  logger,
LoggerFacility  facility,
PARCLogLevel  minimumLevel 
)

Sets the minimum log level for a facility

The default log level is ERROR. For a message to be logged, it must be of equal or higher log level.

Parameters
[in]loggerAn allocated logger
[in]facilityThe facility to set the log level for
[in]Theminimum level to log

◆ logger_SetReporter()

void logger_SetReporter ( Logger *  logger,
PARCLogReporter *  reporter 
)

Switch the logger to a new reporter

Will close the old reporter and re-setup the internal loggers to use the new reporter. All current log level settings are preserved.

Parameters
[in]loggerAn allocated Logger
[in]reporterAn allocated PARCLogReporter