gwenhywfar  5.10.1
Functions | Variables
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>
Include dependency graph for logger.c:

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)
 
int GWEN_Logger_CreateLogMessage (const char *logDomain, GWEN_LOGGER_LEVEL priority, const char *s, GWEN_BUFFER *mbuf)
 
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)
 
void 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 (void)
 
int GWEN_Logger_ModuleInit (void)
 
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

◆ GWEN_Logger__CreateMessage()

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

Definition at line 331 of file logger.c.

References GWEN_Buffer_AppendByte(), and GWEN_Buffer_AppendString().

Referenced by GWEN_Logger__Log(), and GWEN_Logger_CreateLogMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger__Log()

int GWEN_Logger__Log ( GWEN_LOGGER *  lg,
GWEN_LOGGER_LEVEL  priority,
const char *  s 
)

◆ GWEN_Logger_AddLogger()

void GWEN_Logger_AddLogger ( GWEN_LOGGER *  oldLogger,
GWEN_LOGGER *  newLogger 
)

Definition at line 206 of file logger.c.

References GWEN_LIST_ADD.

◆ GWEN_Logger_Attach()

void GWEN_Logger_Attach ( GWEN_LOGGER *  lg)

Definition at line 198 of file logger.c.

◆ GWEN_Logger_Close()

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

Definition at line 298 of file logger.c.

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

Here is the call graph for this function:

◆ GWEN_Logger_CreateLogMessage()

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.

Definition at line 410 of file logger.c.

References GWEN_Logger__CreateMessage(), and GWEN_LoggerDomain_GetLogger().

Referenced by _logHook().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_Enable()

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
fif 0 then logging is disabled, otherwise it is enabled

Definition at line 605 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Here is the call graph for this function:

◆ GWEN_Logger_Exists()

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 811 of file logger.c.

References GWEN_LoggerDomain_Find().

Here is the call graph for this function:

◆ GWEN_Logger_free()

void GWEN_Logger_free ( GWEN_LOGGER *  lg)

Definition at line 184 of file logger.c.

References GWEN_FREE_OBJECT.

Referenced by GWEN_LoggerDomain_free().

Here is the caller graph for this function:

◆ GWEN_Logger_GetLevel()

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

Definition at line 638 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_HttpSession__RecvPacket(), GWEN_SyncIo_Http_ReadHeader(), GWEN_SyncIo_Http_ReadStatus(), GWEN_SyncIo_Http_WriteCommand(), and GWEN_SyncIo_Http_WriteHeader().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_IsEnabled()

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

Definition at line 616 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Here is the call graph for this function:

◆ GWEN_Logger_IsOpen()

int GWEN_Logger_IsOpen ( const char *  logDomain)

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

Definition at line 318 of file logger.c.

References GWEN_LoggerDomain_Find().

Here is the call graph for this function:

◆ GWEN_Logger_Level2Name()

const char* GWEN_Logger_Level2Name ( GWEN_LOGGER_LEVEL  level)

◆ GWEN_Logger_Log()

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
prioritypriority of the message
sstring 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 553 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_Logtype2Name()

const char* GWEN_Logger_Logtype2Name ( GWEN_LOGGER_LOGTYPE  lt)

Transforms a log type into an ASCII string.

Definition at line 784 of file logger.c.

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

◆ GWEN_Logger_ModuleFini()

int GWEN_Logger_ModuleFini ( void  )

Definition at line 81 of file logger.c.

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

Referenced by GWEN_Fini().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_ModuleInit()

int GWEN_Logger_ModuleInit ( void  )

Definition at line 59 of file logger.c.

References GWEN_LOGDOMAIN, GWEN_Logger_Name2Level(), GWEN_Logger_Open(), GWEN_Logger_SetLevel(), GWEN_LoggerFacility_User, GWEN_LoggerLevel_Unknown, GWEN_LoggerLevel_Warning, and GWEN_LoggerType_Console.

Referenced by GWEN_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_Name2Level()

GWEN_LOGGER_LEVEL GWEN_Logger_Name2Level ( const char *  name)

◆ GWEN_Logger_Name2Logtype()

GWEN_LOGGER_LOGTYPE GWEN_Logger_Name2Logtype ( const char *  name)

Transforms an ASCII string into the corresponding log type.

Definition at line 767 of file logger.c.

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

Referenced by checkArgs().

Here is the caller graph for this function:

◆ GWEN_Logger_new()

GWEN_LOGGER* GWEN_Logger_new ( GWEN_LOGGER_DOMAIN *  domain)

Definition at line 169 of file logger.c.

References GWEN_LoggerLevel_Error, GWEN_LoggerType_Console, and GWEN_NEW_OBJECT.

Referenced by GWEN_LoggerDomain_GetLogger().

Here is the caller graph for this function:

◆ GWEN_Logger_Open()

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
identthis string is prepended to each message logged to identify the logging program
filename 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.
logtypehow to log (via syslog, to a file, to the console etc)
facilitywhat kind of program the log message comes from

Definition at line 225 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(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_SetDefaultLogger()

void GWEN_Logger_SetDefaultLogger ( GWEN_UNUSED GWEN_LOGGER *  lg)

Definition at line 217 of file logger.c.

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

Definition at line 666 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_Logger_Open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_SetIdent()

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

Definition at line 650 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_Logger_Open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_SetLevel()

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
lmaximum level to be logged

Definition at line 627 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Referenced by GWEN_Logger_ModuleInit(), main(), test1(), test10(), test2(), test3(), test8(), and test9().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Logger_SetLogFunction()

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

Definition at line 682 of file logger.c.

References GWEN_LoggerDomain_GetLogger().

Here is the call graph for this function:

◆ GWEN_LoggerDomain_Add()

void GWEN_LoggerDomain_Add ( GWEN_LOGGER_DOMAIN *  ld)

Definition at line 133 of file logger.c.

References GWEN_LIST_INSERT, and gwen_loggerdomains.

Referenced by GWEN_LoggerDomain_GetLogger().

Here is the caller graph for this function:

◆ GWEN_LoggerDomain_Del()

void GWEN_LoggerDomain_Del ( GWEN_LOGGER_DOMAIN *  ld)

Definition at line 141 of file logger.c.

References GWEN_LIST_DEL, and gwen_loggerdomains.

Referenced by GWEN_Logger_Close(), and GWEN_Logger_ModuleFini().

Here is the caller graph for this function:

◆ GWEN_LoggerDomain_Find()

GWEN_LOGGER_DOMAIN* GWEN_LoggerDomain_Find ( const char *  name)

Definition at line 116 of file logger.c.

References gwen_loggerdomains.

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

Here is the caller graph for this function:

◆ GWEN_LoggerDomain_free()

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_LoggerDomain_GetLogger()

GWEN_LOGGER* GWEN_LoggerDomain_GetLogger ( const char *  name)

◆ GWEN_LoggerDomain_new()

GWEN_LOGGER_DOMAIN* GWEN_LoggerDomain_new ( const char *  name)

Definition at line 94 of file logger.c.

References GWEN_NEW_OBJECT.

Referenced by GWEN_LoggerDomain_GetLogger().

Here is the caller graph for this function:

Variable Documentation

◆ gwen_loggerdomains

GWEN_LOGGER_DOMAIN* gwen_loggerdomains =0
static