logger.c File Reference

#include <gwenhywfar/gwenhywfarapi.h>
#include <gwenhywfar/misc.h>
#include <gwenhywfar/buffer.h>
#include <gwenhywfar/gui.h>
#include "logger_p.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

Go to the source code of this file.

Functions

int GWEN_Logger__CreateMessage (GWEN_LOGGER *lg, GWEN_LOGGER_LEVEL priority, const char *s, GWEN_BUFFER *mbuf)
int GWEN_Logger__Log (GWEN_LOGGER *lg, GWEN_LOGGER_LEVEL priority, const char *s)
void GWEN_Logger_AddLogger (GWEN_LOGGER *oldLogger, GWEN_LOGGER *newLogger)
void GWEN_Logger_Attach (GWEN_LOGGER *lg)
void GWEN_Logger_Close (const char *logDomain)
void GWEN_Logger_Enable (const char *logDomain, int f)
int GWEN_Logger_Exists (const char *logDomain)
void GWEN_Logger_free (GWEN_LOGGER *lg)
int GWEN_Logger_GetLevel (const char *logDomain)
int GWEN_Logger_IsEnabled (const char *logDomain)
int GWEN_Logger_IsOpen (const char *logDomain)
const char * GWEN_Logger_Level2Name (GWEN_LOGGER_LEVEL level)
int GWEN_Logger_Log (const char *logDomain, GWEN_LOGGER_LEVEL priority, const char *s)
const char * GWEN_Logger_Logtype2Name (GWEN_LOGGER_LOGTYPE lt)
int GWEN_Logger_ModuleFini ()
int GWEN_Logger_ModuleInit ()
GWEN_LOGGER_LEVEL GWEN_Logger_Name2Level (const char *name)
GWEN_LOGGER_LOGTYPE GWEN_Logger_Name2Logtype (const char *name)
GWEN_LOGGER * GWEN_Logger_new (GWEN_LOGGER_DOMAIN *domain)
int GWEN_Logger_Open (const char *logDomain, const char *ident, const char *file, GWEN_LOGGER_LOGTYPE logtype, GWEN_LOGGER_FACILITY facility)
void GWEN_Logger_SetDefaultLogger (GWEN_UNUSED GWEN_LOGGER *lg)
void GWEN_Logger_SetFilename (const char *logDomain, const char *name)
void GWEN_Logger_SetIdent (const char *logDomain, const char *id)
void GWEN_Logger_SetLevel (const char *logDomain, GWEN_LOGGER_LEVEL l)
GWEN_LOGGERFUNCTIONLOG GWEN_Logger_SetLogFunction (const char *logDomain, GWEN_LOGGERFUNCTIONLOG fn)
void GWEN_LoggerDomain_Add (GWEN_LOGGER_DOMAIN *ld)
void GWEN_LoggerDomain_Del (GWEN_LOGGER_DOMAIN *ld)
GWEN_LOGGER_DOMAIN * GWEN_LoggerDomain_Find (const char *name)
void GWEN_LoggerDomain_free (GWEN_LOGGER_DOMAIN *ld)
GWEN_LOGGER * GWEN_LoggerDomain_GetLogger (const char *name)
GWEN_LOGGER_DOMAIN * GWEN_LoggerDomain_new (const char *name)

Variables

static GWEN_LOGGER_DOMAIN * gwen_loggerdomains = 0

Function Documentation

int GWEN_Logger__CreateMessage ( GWEN_LOGGER *  lg,
GWEN_LOGGER_LEVEL  priority,
const char *  s,
GWEN_BUFFER mbuf 
)

Definition at line 315 of file logger.c.

References GWEN_Buffer_AppendByte(), and GWEN_Buffer_AppendString().

Referenced by GWEN_Logger__Log().

int GWEN_Logger__Log ( GWEN_LOGGER *  lg,
GWEN_LOGGER_LEVEL  priority,
const char *  s 
)
void GWEN_Logger_AddLogger ( GWEN_LOGGER *  oldLogger,
GWEN_LOGGER *  newLogger 
)

Definition at line 198 of file logger.c.

References GWEN_LIST_ADD.

void GWEN_Logger_Attach ( GWEN_LOGGER *  lg  ) 

Definition at line 191 of file logger.c.

void GWEN_Logger_Close ( const char *  logDomain  ) 

Shuts down logging. Automatically disables logging.

Author:
Martin Preuss<martin@libchipcard.de>

Definition at line 284 of file logger.c.

References GWEN_Logger_Log(), GWEN_LoggerDomain_Del(), GWEN_LoggerDomain_free(), GWEN_LoggerDomain_GetLogger(), GWEN_LoggerLevel_Debug, and GWEN_LoggerType_Console.

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

Definition at line 572 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

int GWEN_Logger_Exists ( const char *  logDomain  ) 

Checks whether a given log domain already exists.

Returns:
1 if it exists, 0 otherwise

Definition at line 751 of file logger.c.

References GWEN_LoggerDomain_Find().

void GWEN_Logger_free ( GWEN_LOGGER *  lg  ) 

Definition at line 178 of file logger.c.

References GWEN_FREE_OBJECT.

Referenced by GWEN_LoggerDomain_free().

int GWEN_Logger_GetLevel ( const char *  logDomain  ) 

Returns the current log level.

Author:
Martin Preuss<martin@libchipcard.de>

Definition at line 602 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_IpcManager__HandlePacket(), GWEN_IpcManager__RemoveNodeRequestMessages(), and GWEN_IpcRequest_ReadDb().

int GWEN_Logger_IsEnabled ( const char *  logDomain  ) 

Checks whether logging is enabled.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
0 if disabled, 1 otherwise

Definition at line 582 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

int GWEN_Logger_IsOpen ( const char *  logDomain  ) 

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

Definition at line 303 of file logger.c.

References GWEN_LoggerDomain_Find().

const char* GWEN_Logger_Level2Name ( GWEN_LOGGER_LEVEL  level  ) 
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

Definition at line 521 of file logger.c.

References GWEN_Buffer_AppendByte(), GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_Gui_LogHook(), GWEN_Logger__Log(), and GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_Logger_Close(), GWEN_Logger_Open(), and GWEN_Text_LogString().

const char* GWEN_Logger_Logtype2Name ( GWEN_LOGGER_LOGTYPE  lt  ) 

Transforms a log type into an ASCII string.

Definition at line 730 of file logger.c.

References GWEN_LoggerType_Console, GWEN_LoggerType_File, GWEN_LoggerType_Function, GWEN_LoggerType_Syslog, and GWEN_LoggerType_Unknown.

int GWEN_Logger_ModuleFini (  ) 

Definition at line 83 of file logger.c.

References GWEN_LoggerDomain_Del(), GWEN_LoggerDomain_free(), and gwen_loggerdomains.

Referenced by GWEN_Fini().

int GWEN_Logger_ModuleInit (  ) 
GWEN_LOGGER_LEVEL GWEN_Logger_Name2Level ( const char *  name  ) 
GWEN_LOGGER_LOGTYPE GWEN_Logger_Name2Logtype ( const char *  name  ) 

Transforms an ASCII string into the corresponding log type.

Definition at line 714 of file logger.c.

References GWEN_LoggerType_Console, GWEN_LoggerType_File, GWEN_LoggerType_Function, GWEN_LoggerType_Syslog, and GWEN_LoggerType_Unknown.

GWEN_LOGGER* GWEN_Logger_new ( GWEN_LOGGER_DOMAIN *  domain  ) 

Definition at line 164 of file logger.c.

References GWEN_LoggerLevel_Error, GWEN_LoggerType_Console, and GWEN_NEW_OBJECT.

Referenced by GWEN_LoggerDomain_GetLogger().

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

Definition at line 213 of file logger.c.

References GWEN_Logger_Log(), GWEN_Logger_SetFilename(), GWEN_Logger_SetIdent(), GWEN_LoggerDomain_GetLogger(), GWEN_LoggerFacility_Auth, GWEN_LoggerFacility_Daemon, GWEN_LoggerFacility_Mail, GWEN_LoggerFacility_News, GWEN_LoggerFacility_Unknown, GWEN_LoggerFacility_User, GWEN_LoggerLevel_Debug, GWEN_LoggerType_Console, GWEN_LoggerType_File, and GWEN_LoggerType_Syslog.

Referenced by GWEN_Logger_ModuleInit().

void GWEN_Logger_SetDefaultLogger ( GWEN_UNUSED GWEN_LOGGER *  lg  ) 

Definition at line 207 of file logger.c.

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

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

Definition at line 628 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_Logger_Open().

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>

Definition at line 613 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_Logger_Open().

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

Definition at line 592 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_Logger_ModuleInit().

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>

Definition at line 643 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

void GWEN_LoggerDomain_Add ( GWEN_LOGGER_DOMAIN *  ld  ) 

Definition at line 131 of file logger.c.

References GWEN_LIST_INSERT, and gwen_loggerdomains.

Referenced by GWEN_LoggerDomain_GetLogger().

void GWEN_LoggerDomain_Del ( GWEN_LOGGER_DOMAIN *  ld  ) 

Definition at line 138 of file logger.c.

References GWEN_LIST_DEL, and gwen_loggerdomains.

Referenced by GWEN_Logger_Close(), and GWEN_Logger_ModuleFini().

GWEN_LOGGER_DOMAIN* GWEN_LoggerDomain_Find ( const char *  name  ) 

Definition at line 115 of file logger.c.

References gwen_loggerdomains.

Referenced by GWEN_Logger_Exists(), GWEN_Logger_IsOpen(), and GWEN_LoggerDomain_GetLogger().

void GWEN_LoggerDomain_free ( GWEN_LOGGER_DOMAIN *  ld  ) 

Definition at line 106 of file logger.c.

References GWEN_FREE_OBJECT, and GWEN_Logger_free().

Referenced by GWEN_Logger_Close(), and GWEN_Logger_ModuleFini().

GWEN_LOGGER* GWEN_LoggerDomain_GetLogger ( const char *  name  ) 
GWEN_LOGGER_DOMAIN* GWEN_LoggerDomain_new ( const char *  name  ) 

Definition at line 95 of file logger.c.

References GWEN_NEW_OBJECT.

Referenced by GWEN_LoggerDomain_GetLogger().


Variable Documentation

GWEN_LOGGER_DOMAIN* gwen_loggerdomains = 0 [static]

Generated on Sat Jan 2 09:32:38 2010 for gwenhywfar by  doxygen 1.6.1