syslog: cs/minor changes

This commit is contained in:
Jay Sorg 2012-06-04 12:51:22 -07:00
parent 5cd7e29a9f
commit dbd2cbca8e
4 changed files with 243 additions and 254 deletions

View File

@ -1,20 +1,24 @@
/* /*
This program is free software; you can redistribute it and/or modify Copyright (c) 2005-2012 Jay Sorg
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, Permission is hereby granted, free of charge, to any person obtaining a
but WITHOUT ANY WARRANTY; without even the implied warranty of copy of this software and associated documentation files (the "Software"),
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the to deal in the Software without restriction, including without limitation
GNU General Public License for more details. the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
You should have received a copy of the GNU General Public License The above copyright notice and this permission notice shall be included
along with this program; if not, write to the Free Software in all copies or substantial portions of the Software.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2010
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -25,7 +29,9 @@
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include "list.h" #include "list.h"
#include "file.h"
#include "os_calls.h" #include "os_calls.h"
#include "thread_calls.h"
/* Add a define here so that the log.h will hold more information /* Add a define here so that the log.h will hold more information
* when compiled from this C file. * when compiled from this C file.
@ -37,8 +43,8 @@
/* Here we store the current state and configuration of the log */ /* Here we store the current state and configuration of the log */
static struct log_config* staticLogConfig = NULL; static struct log_config* staticLogConfig = NULL;
/*This file first start with all private functions. /* This file first start with all private functions.
In the end of the file the public functions is defined*/ In the end of the file the public functions is defined */
/** /**
* *
@ -50,12 +56,13 @@ static struct log_config* staticLogConfig = NULL;
int DEFAULT_CC int DEFAULT_CC
internal_log_file_open(const char* fname) internal_log_file_open(const char* fname)
{ {
int ret = -1 ; int ret = -1;
if(fname!=NULL) if (fname != NULL)
{ {
ret = open(fname, O_WRONLY | O_CREAT | O_APPEND | O_SYNC, S_IRUSR |S_IWUSR); ret = open(fname, O_WRONLY | O_CREAT | O_APPEND | O_SYNC,
S_IRUSR | S_IWUSR);
} }
return ret ; return ret;
} }
/** /**
@ -119,8 +126,6 @@ internal_log_lvl2str(const enum logLevels lvl, char* str)
} }
} }
/******************************************************************************/
/******************************************************************************/ /******************************************************************************/
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
internal_log_start(struct log_config* l_cfg) internal_log_start(struct log_config* l_cfg)
@ -136,14 +141,14 @@ internal_log_start(struct log_config* l_cfg)
if (0 == l_cfg->log_file) if (0 == l_cfg->log_file)
{ {
g_writeln("log_file not properly assigned"); g_writeln("log_file not properly assigned");
return ret ; return ret;
} }
/* if progname is NULL, we ureturn error */ /* if progname is NULL, we ureturn error */
if (0 == l_cfg->program_name) if (0 == l_cfg->program_name)
{ {
g_writeln("program_name not properly assigned"); g_writeln("program_name not properly assigned");
return ret ; return ret;
} }
/* open file */ /* open file */
@ -172,7 +177,7 @@ internal_log_start(struct log_config* l_cfg)
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
internal_log_end(struct log_config* l_cfg) internal_log_end(struct log_config* l_cfg)
{ {
enum logReturns ret = LOG_GENERAL_ERROR ; enum logReturns ret = LOG_GENERAL_ERROR;
/* if log is closed, quit silently */ /* if log is closed, quit silently */
if (0 == l_cfg) if (0 == l_cfg)
{ {
@ -205,8 +210,8 @@ internal_log_end(struct log_config* l_cfg)
g_free(l_cfg->program_name); g_free(l_cfg->program_name);
l_cfg->program_name = 0; l_cfg->program_name = 0;
} }
ret = LOG_STARTUP_OK ; ret = LOG_STARTUP_OK;
return ret ; return ret;
} }
/** /**
@ -248,30 +253,32 @@ internal_log_text2level(char* buf)
} }
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
internalReadConfiguration(const char *inFilename,const char *applicationName) internalReadConfiguration(const char* inFilename, const char* applicationName)
{ {
int fd; int fd;
enum logReturns ret = LOG_GENERAL_ERROR ; enum logReturns ret = LOG_GENERAL_ERROR;
struct list* sec; struct list* sec;
struct list* param_n; struct list* param_n;
struct list* param_v; struct list* param_v;
if(inFilename==NULL) if (inFilename == NULL)
{ {
g_writeln("The inifile is null to readConfiguration!"); g_writeln("The inifile is null to readConfiguration!");
return ret ; return ret;
} }
fd = g_file_open(inFilename); fd = g_file_open(inFilename);
if (-1 == fd) if (-1 == fd)
{ {
ret = LOG_ERROR_NO_CFG ; ret = LOG_ERROR_NO_CFG;
g_writeln("We could not open the configuration file to read log parameters"); g_writeln("We could not open the configuration file to read log parameters");
return ret ; return ret;
} }
// we initialize the memory for the configuration and set all content to zero. /* we initialize the memory for the configuration and set all content
to zero. */
ret = internalInitAndAllocStruct(); ret = internalInitAndAllocStruct();
if(ret!=LOG_STARTUP_OK){ if (ret != LOG_STARTUP_OK)
return ret ; {
return ret;
} }
sec = list_create(); sec = list_create();
@ -285,23 +292,24 @@ internalReadConfiguration(const char *inFilename,const char *applicationName)
/* read logging config */ /* read logging config */
ret = internal_config_read_logging(fd, staticLogConfig, param_n, ret = internal_config_read_logging(fd, staticLogConfig, param_n,
param_v, applicationName); param_v, applicationName);
if(ret!=LOG_STARTUP_OK) if (ret != LOG_STARTUP_OK)
{ {
return ret ; return ret;
} }
/* cleanup */ /* cleanup */
list_delete(sec); list_delete(sec);
list_delete(param_v); list_delete(param_v);
list_delete(param_n); list_delete(param_n);
g_file_close(fd); g_file_close(fd);
return ret ; return ret;
} }
/******************************************************************************/ /******************************************************************************/
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
internal_config_read_logging(int file, struct log_config* lc, struct list* param_n, internal_config_read_logging(int file, struct log_config* lc,
struct list* param_v,const char *applicationName) struct list* param_n,
struct list* param_v,
const char* applicationName)
{ {
int i; int i;
char* buf; char* buf;
@ -341,11 +349,11 @@ internal_config_read_logging(int file, struct log_config* lc, struct list* param
if (0 == lc->log_file) if (0 == lc->log_file)
{ {
lc->log_file=g_strdup("./sesman.log"); lc->log_file = g_strdup("./sesman.log");
} }
g_printf("logging configuration:\r\n"); g_printf("logging configuration:\r\n");
g_printf("\tLogFile: %s\r\n",lc->log_file); g_printf("\tLogFile: %s\r\n", lc->log_file);
g_printf("\tLogLevel: %i\r\n", lc->log_level); g_printf("\tLogLevel: %i\r\n", lc->log_level);
g_printf("\tEnableSyslog: %i\r\n", lc->enable_syslog); g_printf("\tEnableSyslog: %i\r\n", lc->enable_syslog);
g_printf("\tSyslogLevel: %i\r\n", lc->syslog_level); g_printf("\tSyslogLevel: %i\r\n", lc->syslog_level);
@ -353,22 +361,22 @@ internal_config_read_logging(int file, struct log_config* lc, struct list* param
} }
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
internalInitAndAllocStruct() internalInitAndAllocStruct(void)
{ {
enum logReturns ret = LOG_GENERAL_ERROR ; enum logReturns ret = LOG_GENERAL_ERROR;
staticLogConfig = g_malloc(sizeof(struct log_config),1); staticLogConfig = g_malloc(sizeof(struct log_config), 1);
if(staticLogConfig!=NULL) if (staticLogConfig != NULL)
{ {
staticLogConfig->fd = -1; staticLogConfig->fd = -1;
staticLogConfig->enable_syslog = 0 ; staticLogConfig->enable_syslog = 0;
ret = LOG_STARTUP_OK ; ret = LOG_STARTUP_OK;
} }
else else
{ {
g_writeln("could not allocate memory for log struct") ; g_writeln("could not allocate memory for log struct");
ret = LOG_ERROR_MALLOC ; ret = LOG_ERROR_MALLOC;
} }
return ret ; return ret;
} }
/* /*
@ -395,52 +403,50 @@ text2bool(char* s)
return 0; return 0;
} }
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
log_start_from_param(const struct log_config* iniParams) log_start_from_param(const struct log_config* iniParams)
{ {
enum logReturns ret = LOG_GENERAL_ERROR ; enum logReturns ret = LOG_GENERAL_ERROR;
if(staticLogConfig!=NULL) if (staticLogConfig != NULL)
{ {
log_message(LOG_LEVEL_ALWAYS,"Log already initialized"); log_message(LOG_LEVEL_ALWAYS, "Log already initialized");
return ret ; return ret;
} }
if(iniParams==NULL) if (iniParams == NULL)
{ {
g_writeln("inparam to log_start_from_param is NULL"); g_writeln("inparam to log_start_from_param is NULL");
return ret ; return ret;
} }
else else
{ {
/*Copy the struct information*/ /*Copy the struct information*/
ret = internalInitAndAllocStruct(); ret = internalInitAndAllocStruct();
if(ret!=LOG_STARTUP_OK) if (ret != LOG_STARTUP_OK)
{ {
return ret ; return ret;
} }
staticLogConfig->enable_syslog = iniParams->enable_syslog; staticLogConfig->enable_syslog = iniParams->enable_syslog;
staticLogConfig->fd = iniParams->fd; staticLogConfig->fd = iniParams->fd;
staticLogConfig->log_file = g_strdup(iniParams->log_file); staticLogConfig->log_file = g_strdup(iniParams->log_file);
staticLogConfig->log_level = iniParams->log_level ; staticLogConfig->log_level = iniParams->log_level;
staticLogConfig->log_lock = iniParams->log_lock ; staticLogConfig->log_lock = iniParams->log_lock;
staticLogConfig->log_lock_attr = iniParams->log_lock_attr ; staticLogConfig->log_lock_attr = iniParams->log_lock_attr;
staticLogConfig->program_name = g_strdup(iniParams->program_name); staticLogConfig->program_name = g_strdup(iniParams->program_name);
staticLogConfig->syslog_level = iniParams->syslog_level; staticLogConfig->syslog_level = iniParams->syslog_level;
ret = internal_log_start(staticLogConfig); ret = internal_log_start(staticLogConfig);
if(ret!=LOG_STARTUP_OK) if (ret != LOG_STARTUP_OK)
{ {
g_writeln("Could not start log"); g_writeln("Could not start log");
if(staticLogConfig!=NULL) if (staticLogConfig != NULL)
{ {
g_free(staticLogConfig); g_free(staticLogConfig);
staticLogConfig = NULL ; staticLogConfig = NULL;
} }
} }
} }
return ret ; return ret;
} }
/** /**
* This function initialize the log facilities according to the configuration * This function initialize the log facilities according to the configuration
* file, that is described by the in parameter. * file, that is described by the in parameter.
@ -449,32 +455,34 @@ log_start_from_param(const struct log_config* iniParams)
* @return 0 on success * @return 0 on success
*/ */
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
log_start(const char *iniFile, const char *applicationName) log_start(const char* iniFile, const char* applicationName)
{ {
enum logReturns ret = LOG_GENERAL_ERROR ; enum logReturns ret = LOG_GENERAL_ERROR;
if(applicationName==NULL) if (applicationName == NULL)
{ {
g_writeln("Programming error your application name cannot be null"); g_writeln("Programming error your application name cannot be null");
return ret ; return ret;
} }
ret = internalReadConfiguration(iniFile, applicationName) ; ret = internalReadConfiguration(iniFile, applicationName);
if(ret==LOG_STARTUP_OK) if (ret == LOG_STARTUP_OK)
{ {
ret = internal_log_start(staticLogConfig); ret = internal_log_start(staticLogConfig);
if(ret!=LOG_STARTUP_OK) if (ret != LOG_STARTUP_OK)
{ {
g_writeln("Could not start log"); g_writeln("Could not start log");
if(staticLogConfig!=NULL){ if (staticLogConfig != NULL)
{
g_free(staticLogConfig); g_free(staticLogConfig);
staticLogConfig = NULL ; staticLogConfig = NULL;
} }
} }
} }
else else
{ {
g_writeln("Error reading configuration for log based on config: %s",iniFile); g_writeln("Error reading configuration for log based on config: %s",
iniFile);
} }
return ret ; return ret;
} }
/** /**
@ -482,36 +490,34 @@ log_start(const char *iniFile, const char *applicationName)
* @return * @return
*/ */
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
log_end() log_end(void)
{ {
enum logReturns ret = LOG_GENERAL_ERROR; enum logReturns ret = LOG_GENERAL_ERROR;
ret = internal_log_end(staticLogConfig); ret = internal_log_end(staticLogConfig);
if(staticLogConfig!=NULL) if (staticLogConfig != NULL)
{ {
g_free(staticLogConfig); g_free(staticLogConfig);
staticLogConfig = NULL ; staticLogConfig = NULL;
} }
return ret ; return ret;
} }
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
log_message( const enum logLevels lvl, log_message(const enum logLevels lvl, const char* msg, ...)
const char* msg, ...)
{ {
char buff[LOG_BUFFER_SIZE + 31]; /* 19 (datetime) 4 (space+cr+lf+\0) */ char buff[LOG_BUFFER_SIZE + 31]; /* 19 (datetime) 4 (space+cr+lf+\0) */
va_list ap; va_list ap;
int len = 0; int len = 0;
enum logReturns rv = LOG_STARTUP_OK; enum logReturns rv = LOG_STARTUP_OK;
int writereply = 0 ; int writereply = 0;
time_t now_t; time_t now_t;
struct tm* now; struct tm* now;
enum logReturns ret = LOG_GENERAL_ERROR; if (staticLogConfig == NULL)
if(staticLogConfig==NULL)
{ {
g_writeln("The log reference is NULL - log not initialized properly"); g_writeln("The log reference is NULL - log not initialized properly");
return LOG_ERROR_NO_CFG; return LOG_ERROR_NO_CFG;
} }
if (0 > staticLogConfig->fd && staticLogConfig->enable_syslog==0) if (0 > staticLogConfig->fd && staticLogConfig->enable_syslog == 0)
{ {
return LOG_ERROR_FILE_NOT_OPEN; return LOG_ERROR_FILE_NOT_OPEN;
} }
@ -519,8 +525,8 @@ const char* msg, ...)
now_t = time(&now_t); now_t = time(&now_t);
now = localtime(&now_t); now = localtime(&now_t);
snprintf(buff, 21, "[%.4d%.2d%.2d-%.2d:%.2d:%.2d] ", (now->tm_year) + 1900, snprintf(buff, 21, "[%.4d%.2d%.2d-%.2d:%.2d:%.2d] ", now->tm_year + 1900,
(now->tm_mon) + 1, now->tm_mday, now->tm_hour, now->tm_min, now->tm_mon + 1, now->tm_mday, now->tm_hour, now->tm_min,
now->tm_sec); now->tm_sec);
internal_log_lvl2str(lvl, buff + 20); internal_log_lvl2str(lvl, buff + 20);
@ -532,44 +538,45 @@ const char* msg, ...)
/* checking for truncated messages */ /* checking for truncated messages */
if (len > LOG_BUFFER_SIZE) if (len > LOG_BUFFER_SIZE)
{ {
log_message(LOG_LEVEL_WARNING,"next message will be truncated"); log_message(LOG_LEVEL_WARNING, "next message will be truncated");
} }
/* forcing the end of message string */ /* forcing the end of message string */
#ifdef _WIN32 #ifdef _WIN32
buff[len + 28] = '\r'; buff[len + 28] = '\r';
buff[len + 29] = '\n'; buff[len + 29] = '\n';
buff[len + 30] = '\0'; buff[len + 30] = '\0';
#else #else
#ifdef _MACOS #ifdef _MACOS
buff[len + 28] = '\r'; buff[len + 28] = '\r';
buff[len + 29] = '\0'; buff[len + 29] = '\0';
#else #else
buff[len + 28] = '\n'; buff[len + 28] = '\n';
buff[len + 29] = '\0'; buff[len + 29] = '\0';
#endif #endif
#endif #endif
if (staticLogConfig->enable_syslog && (lvl <= staticLogConfig->syslog_level)) if (staticLogConfig->enable_syslog && (lvl <= staticLogConfig->syslog_level))
{ {
/* log to syslog*/ /* log to syslog*/
/* %s fix compiler warning 'not a string literal' */ /* %s fix compiler warning 'not a string literal' */
syslog(internal_log_xrdp2syslog(lvl), "(%d)(%d)%s",g_getpid(),g_gettid(),(char *)(buff + 20)); syslog(internal_log_xrdp2syslog(lvl), "(%d)(%ld)%s", g_getpid(),
tc_get_threadid(), buff + 20);
} }
if (lvl <= staticLogConfig->log_level) if (lvl <= staticLogConfig->log_level)
{ {
/* log to console */ /* log to console */
g_printf((char*)buff); g_printf(buff);
/* log to application logfile */ /* log to application logfile */
#ifdef LOG_ENABLE_THREAD #ifdef LOG_ENABLE_THREAD
pthread_mutex_lock(&(staticLogConfig->log_lock)); pthread_mutex_lock(&(staticLogConfig->log_lock));
#endif #endif
if(staticLogConfig->fd>0) if (staticLogConfig->fd > 0)
{ {
writereply = g_file_write(staticLogConfig->fd, (char*)buff, g_strlen((char*)buff)); writereply = g_file_write(staticLogConfig->fd, buff, g_strlen(buff));
if(writereply <= 0) if (writereply <= 0)
{ {
rv = LOG_ERROR_NULL_FILE; rv = LOG_ERROR_NULL_FILE;
} }
@ -581,29 +588,27 @@ const char* msg, ...)
return rv; return rv;
} }
/** /**
* Return the configured log file name * Return the configured log file name
* @return * @return
*/ */
char *getLogFile(char *replybuf, int bufsize) char* DEFAULT_CC
getLogFile(char* replybuf, int bufsize)
{ {
if(staticLogConfig ) if (staticLogConfig)
{ {
if(staticLogConfig->log_file) if (staticLogConfig->log_file)
{ {
g_strncpy(replybuf, staticLogConfig->log_file,bufsize); g_strncpy(replybuf, staticLogConfig->log_file, bufsize);
} }
else else
{ {
g_sprintf(replybuf,"The log_file name is NULL"); g_sprintf(replybuf, "The log_file name is NULL");
} }
} }
else else
{ {
g_snprintf(replybuf,bufsize,"The log is not properly started"); g_snprintf(replybuf, bufsize, "The log is not properly started");
} }
return replybuf ; return replybuf;
} }

View File

@ -1,20 +1,24 @@
/* /*
This program is free software; you can redistribute it and/or modify Copyright (c) 2005-2012 Jay Sorg
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, Permission is hereby granted, free of charge, to any person obtaining a
but WITHOUT ANY WARRANTY; without even the implied warranty of copy of this software and associated documentation files (the "Software"),
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the to deal in the Software without restriction, including without limitation
GNU General Public License for more details. the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
You should have received a copy of the GNU General Public License The above copyright notice and this permission notice shall be included
along with this program; if not, write to the Free Software in all copies or substantial portions of the Software.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2010
*/ */
#ifndef LOG_H #ifndef LOG_H
@ -28,7 +32,8 @@
#define LOG_BUFFER_SIZE 1024 #define LOG_BUFFER_SIZE 1024
/* logging levels */ /* logging levels */
enum logLevels{ enum logLevels
{
LOG_LEVEL_ALWAYS = 0, LOG_LEVEL_ALWAYS = 0,
LOG_LEVEL_ERROR, LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING, LOG_LEVEL_WARNING,
@ -37,7 +42,8 @@ enum logLevels{
}; };
/* startup return values */ /* startup return values */
enum logReturns{ enum logReturns
{
LOG_STARTUP_OK = 0, LOG_STARTUP_OK = 0,
LOG_ERROR_MALLOC, LOG_ERROR_MALLOC,
LOG_ERROR_NULL_FILE, LOG_ERROR_NULL_FILE,
@ -57,12 +63,11 @@ enum logReturns{
/*#define LOG_ENABLE_THREAD*/ /*#define LOG_ENABLE_THREAD*/
#ifdef DEBUG #ifdef DEBUG
#define LOG_DBG(args...) log_message(LOG_LEVEL_DEBUG, args); #define LOG_DBG(args...) log_message(LOG_LEVEL_DEBUG, args);
#else #else
#define LOG_DBG(args...) #define LOG_DBG(args...)
#endif #endif
struct log_config struct log_config
{ {
char* program_name; char* program_name;
@ -121,7 +126,7 @@ internal_log_text2level(char* s);
* @return LOG_STARTUP_OK or LOG_ERROR_MALLOC * @return LOG_STARTUP_OK or LOG_ERROR_MALLOC
*/ */
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
internalInitAndAllocStruct(); internalInitAndAllocStruct(void);
/** /**
* Read configuration from a file and store the values in lists. * Read configuration from a file and store the values in lists.
@ -133,8 +138,10 @@ internalInitAndAllocStruct();
* @return * @return
*/ */
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
internal_config_read_logging(int file, struct log_config* lc, struct list* param_n, internal_config_read_logging(int file, struct log_config* lc,
struct list* param_v,const char *applicationName) ; struct list* param_n,
struct list* param_v,
const char *applicationName);
/*End of internal functions*/ /*End of internal functions*/
#endif #endif
/** /**
@ -145,7 +152,7 @@ internal_config_read_logging(int file, struct log_config* lc, struct list* param
* @return LOG_STARTUP_OK on success * @return LOG_STARTUP_OK on success
*/ */
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
log_start(const char *iniFile, const char *applicationName) ; log_start(const char* iniFile, const char* applicationName);
/** /**
* An alternative log_start where the caller gives the params directly. * An alternative log_start where the caller gives the params directly.
@ -159,7 +166,7 @@ log_start_from_param(const struct log_config *iniParams);
* @return * @return
*/ */
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
log_end() ; log_end(void);
/** /**
* the log function that all files use to log an event. * the log function that all files use to log an event.
@ -169,7 +176,7 @@ log_end() ;
* @return * @return
*/ */
enum logReturns DEFAULT_CC enum logReturns DEFAULT_CC
log_message(const enum logLevels lvl, const char* msg, ...) ; log_message(const enum logLevels lvl, const char* msg, ...);
/** /**
* *
@ -189,4 +196,3 @@ int APP_CC text2bool(char* s);
*/ */
char *getLogFile(char *replybuf, int bufsize); char *getLogFile(char *replybuf, int bufsize);
#endif #endif

View File

@ -2218,22 +2218,6 @@ g_getpid(void)
#endif #endif
} }
/*****************************************************************************/
int APP_CC
g_gettid(void)
{
#if defined(_WIN32)
return (int)GetCurrentThreadId();
#else
#if defined(__linux__)
/* This is Linux specific way of getting the thread id.
* Function is not part of GLIB so therefore this syscall*/
return (int)syscall(__NR_gettid);
#else
return (int)pthread_self();
#endif
#endif
}
/*****************************************************************************/ /*****************************************************************************/
/* does not work in win32 */ /* does not work in win32 */
int APP_CC int APP_CC

View File

@ -252,12 +252,6 @@ int APP_CC
g_exit(int exit_code); g_exit(int exit_code);
int APP_CC int APP_CC
g_getpid(void); g_getpid(void);
/**
* Returns the current thread ID
* @return
*/
int APP_CC
g_gettid(void);
int APP_CC int APP_CC
g_sigterm(int pid); g_sigterm(int pid);
int APP_CC int APP_CC