logger.h File Reference
`#include <gwenhywfar/gwenhywfarapi.h>`
`#include <gwenhywfar/buffer.h>`

Go to the source code of this file.

## Macros

#define | GWEN_LOGDOMAIN "gwenhywfar"

## Typedefs

typedef void GWENHYWFAR_CB(* | GWEN_LOGGERFUNCTIONLOG) (const char *s)

## Enumerations

enum | GWEN_LOGGER_FACILITY { GWEN_LoggerFacility_Auth =0 , GWEN_LoggerFacility_Daemon , GWEN_LoggerFacility_Mail , GWEN_LoggerFacility_News , GWEN_LoggerFacility_User , GWEN_LoggerFacility_Unknown =9999 }
enum | GWEN_LOGGER_LEVEL { GWEN_LoggerLevel_Emergency =0 , GWEN_LoggerLevel_Alert , GWEN_LoggerLevel_Critical , GWEN_LoggerLevel_Error , GWEN_LoggerLevel_Warning , GWEN_LoggerLevel_Notice , GWEN_LoggerLevel_Info , GWEN_LoggerLevel_Debug , GWEN_LoggerLevel_Verbous , GWEN_LoggerLevel_Unknown =9999 }
enum | GWEN_LOGGER_LOGTYPE { GWEN_LoggerType_Console , GWEN_LoggerType_File , GWEN_LoggerType_Syslog , GWEN_LoggerType_Function , GWEN_LoggerType_Unknown =9999 }

## Functions

GWENHYWFAR_API void | GWEN_Logger_Close (const char *logDomain)
GWENHYWFAR_API int | GWEN_Logger_CreateLogMessage (const char *logDomain, GWEN_LOGGER_LEVEL priority, const char *s, GWEN_BUFFER *mbuf)
GWENHYWFAR_API void | GWEN_Logger_Enable (const char *logDomain, int f)
GWENHYWFAR_API int | GWEN_Logger_Exists (const char *logDomain)
GWENHYWFAR_API int | GWEN_Logger_GetLevel (const char *logDomain)
GWENHYWFAR_API int | GWEN_Logger_IsEnabled (const char *logDomain)
GWENHYWFAR_API int | GWEN_Logger_IsOpen (const char *logDomain)
GWENHYWFAR_API const char * | GWEN_Logger_Level2Name (GWEN_LOGGER_LEVEL level)
GWENHYWFAR_API void | GWEN_Logger_Log (const char *logDomain, GWEN_LOGGER_LEVEL priority, const char *s)
GWENHYWFAR_API const char * | GWEN_Logger_Logtype2Name (GWEN_LOGGER_LOGTYPE lt)
GWENHYWFAR_API GWEN_LOGGER_LEVEL | GWEN_Logger_Name2Level (const char *name)
GWENHYWFAR_API GWEN_LOGGER_LOGTYPE | GWEN_Logger_Name2Logtype (const char *name)
GWENHYWFAR_API int | GWEN_Logger_Open (const char *logDomain, const char *ident, const char *file, GWEN_LOGGER_LOGTYPE logtype, GWEN_LOGGER_FACILITY facility)
void | GWEN_Logger_SetFilename (const char *logDomain, const char *name)
GWENHYWFAR_API void | GWEN_Logger_SetIdent (const char *logDomain, const char *id)
GWENHYWFAR_API void | GWEN_Logger_SetLevel (const char *logDomain, GWEN_LOGGER_LEVEL l)
GWENHYWFAR_API GWEN_LOGGERFUNCTIONLOG | GWEN_Logger_SetLogFunction (const char *logDomain, GWEN_LOGGERFUNCTIONLOG fn)

## Macro Definition Documentation

## GWEN_LOGDOMAIN

#define GWEN_LOGDOMAIN "gwenhywfar"

Definition at line 32 of file logger.h.

## Typedef Documentation

## GWEN_LOGGERFUNCTIONLOG

typedef void GWENHYWFAR_CB(* GWEN_LOGGERFUNCTIONLOG) (const char *s)

Definition at line 38 of file logger.h.

## Enumeration Type Documentation

## GWEN_LOGGER_FACILITY

enum GWEN_LOGGER_FACILITY

Enumerator
GWEN_LoggerFacility_Auth |
GWEN_LoggerFacility_Daemon |
GWEN_LoggerFacility_Mail |
GWEN_LoggerFacility_News |
GWEN_LoggerFacility_User |
GWEN_LoggerFacility_Unknown |

Definition at line 50 of file logger.h.

## GWEN_LOGGER_LEVEL

enum GWEN_LOGGER_LEVEL

Enumerator
GWEN_LoggerLevel_Emergency |
GWEN_LoggerLevel_Alert |
GWEN_LoggerLevel_Critical |
GWEN_LoggerLevel_Error |
GWEN_LoggerLevel_Warning |
GWEN_LoggerLevel_Notice |
GWEN_LoggerLevel_Info |
GWEN_LoggerLevel_Debug |
GWEN_LoggerLevel_Verbous |
GWEN_LoggerLevel_Unknown |

Definition at line 61 of file logger.h.

## GWEN_LOGGER_LOGTYPE

enum GWEN_LOGGER_LOGTYPE

Enumerator
GWEN_LoggerType_Console |
GWEN_LoggerType_File |
GWEN_LoggerType_Syslog |
GWEN_LoggerType_Function |
GWEN_LoggerType_Unknown |

Definition at line 40 of file logger.h.

## Function Documentation

## GWEN_Logger_Close()

GWENHYWFAR_API void GWEN_Logger_Close | ( | const char * | logDomain | ) |

Shuts down logging. Automatically disables logging.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

References GWENHYWFAR_API.

## GWEN_Logger_CreateLogMessage()

GWENHYWFAR_API int GWEN_Logger_CreateLogMessage | ( | const char * | logDomain,
|  | GWEN_LOGGER_LEVEL | priority,
|  | const char * | s,
|  | GWEN_BUFFER * | mbuf )

This function can be used to generate log messages from within log hooks.

## GWEN_Logger_Enable()

GWENHYWFAR_API void GWEN_Logger_Enable | ( | const char * | logDomain,
|  | int | f )

Enables or disables logging.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

Parameters

  f | if 0 then logging is disabled, otherwise it is enabled

References GWENHYWFAR_API.

## GWEN_Logger_Exists()

GWENHYWFAR_API int GWEN_Logger_Exists | ( | const char * | logDomain | ) |

Checks whether a given log domain already exists.

Returns
  1 if it exists, 0 otherwise

References GWENHYWFAR_API.

## GWEN_Logger_GetLevel()

GWENHYWFAR_API int GWEN_Logger_GetLevel | ( | const char * | logDomain | ) |

Returns the current log level.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

References GWENHYWFAR_API.

## GWEN_Logger_IsEnabled()

GWENHYWFAR_API int GWEN_Logger_IsEnabled | ( | const char * | logDomain | ) |

Checks whether logging is enabled.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

Returns
  0 if disabled, 1 otherwise

References GWENHYWFAR_API.

## GWEN_Logger_IsOpen()

GWENHYWFAR_API int GWEN_Logger_IsOpen | ( | const char * | logDomain | ) |

Checks whether the logger for the given logDomain is open or not.

References GWENHYWFAR_API.

## GWEN_Logger_Level2Name()

GWENHYWFAR_API const char * GWEN_Logger_Level2Name | ( | GWEN_LOGGER_LEVEL | level | ) |

Transforms a logger level to an ASCII string (for config files, command line options etc).

References GWENHYWFAR_API.

## GWEN_Logger_Log()

GWENHYWFAR_API void GWEN_Logger_Log | ( | const char * | logDomain,
|  | GWEN_LOGGER_LEVEL | priority,
|  | const char * | s )

Log a message.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

Parameters

  priority | priority of the message
  s | string to log. This string is cut at all occurences of a newline character thus splitting it into multiple log lines if necessary

References GWENHYWFAR_API.

## GWEN_Logger_Logtype2Name()

GWENHYWFAR_API const char * GWEN_Logger_Logtype2Name | ( | GWEN_LOGGER_LOGTYPE | lt | ) |

Transforms a log type into an ASCII string.

References GWENHYWFAR_API.

## GWEN_Logger_Name2Level()

GWENHYWFAR_API GWEN_LOGGER_LEVEL GWEN_Logger_Name2Level | ( | const char * | name | ) |

Transforms an ASCII string to a level value.

References GWENHYWFAR_API.

## GWEN_Logger_Name2Logtype()

GWENHYWFAR_API GWEN_LOGGER_LOGTYPE GWEN_Logger_Name2Logtype | ( | const char * | name | ) |

Transforms an ASCII string into the corresponding log type.

References GWENHYWFAR_API.

## GWEN_Logger_Open()

GWENHYWFAR_API int GWEN_Logger_Open | ( | const char * | logDomain,
|  | const char * | ident,
|  | const char * | file,
|  | GWEN_LOGGER_LOGTYPE | logtype,
|  | GWEN_LOGGER_FACILITY | facility )

Sets up logging. It automatically enables logging.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

Parameters

  ident | this string is prepended to each message logged to identify the logging program
  file | name of the file to log to. If this is empty and syslog is available, then all messages are logged via syslog. If syslog is not available, all messages are logged to the console.
  logtype | how to log (via syslog, to a file, to the console etc)
  facility | what kind of program the log message comes from

References GWENHYWFAR_API.

## GWEN_Logger_SetFilename()

void GWEN_Logger_SetFilename | ( | const char * | logDomain,
|  | const char * | name )

Set the name of the file to be used when logging to a file.

References GWENHYWFAR_API.

## GWEN_Logger_SetIdent()

GWENHYWFAR_API void GWEN_Logger_SetIdent | ( | const char * | logDomain,
|  | const char * | id )

Set ident string. This string is prepended to every log message and should contain the name of the running program.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

References GWENHYWFAR_API.

## GWEN_Logger_SetLevel()

GWENHYWFAR_API void GWEN_Logger_SetLevel | ( | const char * | logDomain,
|  | GWEN_LOGGER_LEVEL | l )

Sets the logger level. All messages with a priority up to the given one will be logged, all others will not.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

Parameters

  l | maximum level to be logged

References GWENHYWFAR_API.

## GWEN_Logger_SetLogFunction()

GWENHYWFAR_API GWEN_LOGGERFUNCTIONLOG GWEN_Logger_SetLogFunction | ( | const char * | logDomain,
|  | GWEN_LOGGERFUNCTIONLOG | fn )

Set logging function. This function is used to log messages in mode LoggerTypeFunction.

Author
  Martin Preussmarti.nosp@m.n@li.nosp@m.bchip.nosp@m.card.nosp@m..de

References GWENHYWFAR_API.