# logger.h File Reference

`#include <gwenhywfar/gwenhywfarapi.h>`

Go to the source code of this file.

## Defines

#define | GWEN_LOGDOMAIN "gwenhywfar"

## Typedefs

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

## Enumerations

enum | GWEN_LOGGER_FACILITY { GWEN_LoggerFacilityAuth = 0, GWEN_LoggerFacilityDaemon, GWEN_LoggerFacilityMail, GWEN_LoggerFacilityNews, GWEN_LoggerFacilityUser, GWEN_LoggerFacilityUnknown = 9999 }
enum | GWEN_LOGGER_LEVEL { GWEN_LoggerLevelEmergency = 0, GWEN_LoggerLevelAlert, GWEN_LoggerLevelCritical, GWEN_LoggerLevelError, GWEN_LoggerLevelWarning, GWEN_LoggerLevelNotice, GWEN_LoggerLevelInfo, GWEN_LoggerLevelDebug, GWEN_LoggerLevelVerbous, GWEN_LoggerLevelUnknown = 9999 }
enum | GWEN_LOGGER_LOGTYPE { GWEN_LoggerTypeConsole, GWEN_LoggerTypeFile, GWEN_LoggerTypeSyslog, GWEN_LoggerTypeFunction, GWEN_LoggerTypeUnknown = 9999 }

## Functions

GWENHYWFAR_API void | GWEN_Logger_AddLogger (GWEN_LOGGER *oldLogger, GWEN_LOGGER *newLogger)
GWENHYWFAR_API void | GWEN_Logger_Attach (GWEN_LOGGER *lg)
GWENHYWFAR_API void | GWEN_Logger_Close (const char *logDomain)
GWENHYWFAR_API void | GWEN_Logger_Enable (const char *logDomain, int f)
GWENHYWFAR_API int | GWEN_Logger_Exists (const char *logDomain)
GWENHYWFAR_API void | GWEN_Logger_free (GWEN_LOGGER *lg)
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 int | 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 GWEN_LOGGER * | GWEN_Logger_new ()
GWENHYWFAR_API int | GWEN_Logger_Open (const char *logDomain, const char *ident, const char *file, GWEN_LOGGER_LOGTYPE logtype, GWEN_LOGGER_FACILITY facility)
GWENHYWFAR_API void | GWEN_Logger_SetDefaultLogger (GWEN_LOGGER *lg)
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)

## Define Documentation

#define GWEN_LOGDOMAIN "gwenhywfar"

## Typedef Documentation

typedef struct GWEN_LOGGER GWEN_LOGGER

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

## Enumeration Type Documentation

enum GWEN_LOGGER_FACILITY

Enumerator:

  GWEN_LoggerFacilityAuth |
  GWEN_LoggerFacilityDaemon |
  GWEN_LoggerFacilityMail |
  GWEN_LoggerFacilityNews |
  GWEN_LoggerFacilityUser |
  GWEN_LoggerFacilityUnknown |

enum GWEN_LOGGER_LEVEL

Enumerator:

  GWEN_LoggerLevelEmergency |
  GWEN_LoggerLevelAlert |
  GWEN_LoggerLevelCritical |
  GWEN_LoggerLevelError |
  GWEN_LoggerLevelWarning |
  GWEN_LoggerLevelNotice |
  GWEN_LoggerLevelInfo |
  GWEN_LoggerLevelDebug |
  GWEN_LoggerLevelVerbous |
  GWEN_LoggerLevelUnknown |

enum GWEN_LOGGER_LOGTYPE

Enumerator:

  GWEN_LoggerTypeConsole |
  GWEN_LoggerTypeFile |
  GWEN_LoggerTypeSyslog |
  GWEN_LoggerTypeFunction |
  GWEN_LoggerTypeUnknown |

## Function Documentation

GWENHYWFAR_API void GWEN_Logger_AddLogger | ( | GWEN_LOGGER * | oldLogger,
|  | GWEN_LOGGER * | newLogger
| ) |

| Adds a logger to the given one. So if the old logger is to log something then the newly added logger will log the same message as well. The new logger must already be open (via GWEN_Logger_Open).

GWENHYWFAR_API void GWEN_Logger_Attach | ( | GWEN_LOGGER * | lg | ) |

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

Shuts down logging. Automatically disables logging.

Author:
  Martin Preuss<martin@libchipcard.de>

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

Enables or disables logging.

Author:
  Martin Preuss<martin@libchipcard.de>

Parameters:

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

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

Checks whether a given log domain already exists.

Returns:
  1 if it exists, 0 otherwise

GWENHYWFAR_API void GWEN_Logger_free | ( | GWEN_LOGGER * | lg | ) |

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

Returns the current log level.

Author:
  Martin Preuss<martin@libchipcard.de>

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

Checks whether logging is enabled.

Author:
  Martin Preuss<martin@libchipcard.de>

Returns:
  0 if disabled, 1 otherwise

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

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

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).

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

Log a message.

Author:
  Martin Preuss<martin@libchipcard.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

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

| Transforms a log type into an ASCII string.

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

| Transforms an ASCII string to a level value.

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

| Transforms an ASCII string into the corresponding log type.

GWENHYWFAR_API GWEN_LOGGER* GWEN_Logger_new | ( |  | ) |

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 Preuss<martin@libchipcard.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

GWENHYWFAR_API void GWEN_Logger_SetDefaultLogger | ( | GWEN_LOGGER * | lg | ) |

| DEPRECATED. Only sets the new default logger if it not already is set or if the new default logger is NULL. You must call GWEN_Logger_Open on that logger prior to calling this function.

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

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

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 Preuss<martin@libchipcard.de>

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 Preuss<martin@libchipcard.de>

Parameters:

  | l | maximum level to be logged

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 Preuss<martin@libchipcard.de>