#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_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 |
int GWEN_Logger__CreateMessage | ( | GWEN_LOGGER * | lg, | |
GWEN_LOGGER_LEVEL | priority, | |||
const char * | s, | |||
GWEN_BUFFER * | mbuf | |||
) |
Definition at line 314 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 | |||
) |
Definition at line 392 of file logger.c.
References GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_GetUsedBytes(), GWEN_Buffer_new(), GWEN_Logger__CreateMessage(), GWEN_LoggerLevel_Alert, GWEN_LoggerLevel_Critical, GWEN_LoggerLevel_Debug, GWEN_LoggerLevel_Emergency, GWEN_LoggerLevel_Error, GWEN_LoggerLevel_Info, GWEN_LoggerLevel_Notice, GWEN_LoggerLevel_Verbous, GWEN_LoggerLevel_Warning, GWEN_LoggerType_Console, GWEN_LoggerType_File, GWEN_LoggerType_Function, and GWEN_LoggerType_Syslog.
Referenced by GWEN_Logger_Log().
void GWEN_Logger_AddLogger | ( | GWEN_LOGGER * | oldLogger, | |
GWEN_LOGGER * | newLogger | |||
) |
void GWEN_Logger_Close | ( | const char * | logDomain | ) |
Shuts down logging. Automatically disables logging.
Definition at line 283 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.
f | if 0 then logging is disabled, otherwise it is enabled |
Definition at line 569 of file logger.c.
References GWEN_LoggerDomain_GetLogger().
int GWEN_Logger_Exists | ( | const char * | logDomain | ) |
Checks whether a given log domain already exists.
Definition at line 747 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.
Definition at line 599 of file logger.c.
References GWEN_LoggerDomain_GetLogger().
Referenced by GWEN_IpcManager__HandlePacket(), GWEN_IpcManager__RemoveNodeRequestMessages(), and GWEN_IpcRequest_fromDb().
int GWEN_Logger_IsEnabled | ( | const char * | logDomain | ) |
Checks whether logging is enabled.
Definition at line 579 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 302 of file logger.c.
References GWEN_LoggerDomain_Find().
const char* GWEN_Logger_Level2Name | ( | GWEN_LOGGER_LEVEL | level | ) |
Transforms a logger level to an ASCII string (for config files, command line options etc).
Definition at line 680 of file logger.c.
References GWEN_LoggerLevel_Alert, GWEN_LoggerLevel_Critical, GWEN_LoggerLevel_Debug, GWEN_LoggerLevel_Emergency, GWEN_LoggerLevel_Error, GWEN_LoggerLevel_Info, GWEN_LoggerLevel_Notice, GWEN_LoggerLevel_Unknown, GWEN_LoggerLevel_Verbous, and GWEN_LoggerLevel_Warning.
int GWEN_Logger_Log | ( | const char * | logDomain, | |
GWEN_LOGGER_LEVEL | priority, | |||
const char * | s | |||
) |
Log a message.
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 518 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 727 of file logger.c.
References GWEN_LoggerType_Console, GWEN_LoggerType_File, GWEN_LoggerType_Function, and GWEN_LoggerType_Syslog.
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 | ( | ) |
Definition at line 62 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().
GWEN_LOGGER_LEVEL GWEN_Logger_Name2Level | ( | const char * | name | ) |
Transforms an ASCII string to a level value.
Definition at line 654 of file logger.c.
References GWEN_LoggerLevel_Alert, GWEN_LoggerLevel_Critical, GWEN_LoggerLevel_Debug, GWEN_LoggerLevel_Emergency, GWEN_LoggerLevel_Error, GWEN_LoggerLevel_Info, GWEN_LoggerLevel_Notice, GWEN_LoggerLevel_Unknown, GWEN_LoggerLevel_Verbous, and GWEN_LoggerLevel_Warning.
Referenced by GWEN_Logger_ModuleInit().
GWEN_LOGGER_LOGTYPE GWEN_Logger_Name2Logtype | ( | const char * | name | ) |
Transforms an ASCII string into the corresponding log type.
Definition at line 711 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.
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_User, GWEN_LoggerLevel_Debug, GWEN_LoggerType_Console, GWEN_LoggerType_File, and GWEN_LoggerType_Syslog.
Referenced by GWEN_Logger_ModuleInit().
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 625 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.
Definition at line 610 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.
l | maximum level to be logged |
Definition at line 589 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.
Definition at line 640 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 | ) |
Definition at line 145 of file logger.c.
References GWEN_Logger_new(), GWEN_LoggerDomain_Add(), GWEN_LoggerDomain_Find(), and GWEN_LoggerDomain_new().
Referenced by GWEN_Logger_Close(), GWEN_Logger_Enable(), GWEN_Logger_GetLevel(), GWEN_Logger_IsEnabled(), GWEN_Logger_Log(), GWEN_Logger_Open(), GWEN_Logger_SetFilename(), GWEN_Logger_SetIdent(), GWEN_Logger_SetLevel(), and GWEN_Logger_SetLogFunction().
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().
GWEN_LOGGER_DOMAIN* gwen_loggerdomains = 0 [static] |
Definition at line 58 of file logger.c.
Referenced by GWEN_Logger_ModuleFini(), GWEN_LoggerDomain_Add(), GWEN_LoggerDomain_Del(), and GWEN_LoggerDomain_Find().