source/bases/Win32Service.c
//-----------------------------------------------------------------------------
// Service_StartLogging()
//   Initialize logging for the service.
//-----------------------------------------------------------------------------
Service_StartLogging()
Initialize logging for the service.
Service_StartLogging () Initialize logging for the service .
static int Service_StartLogging(void)
{
    wchar_t defaultLogFileName[PATH_MAX + 1], logFileName[PATH_MAX + 1];
    unsigned logLevel, maxFiles, maxFileSize;
    wchar_t *ptr, prefix[CX_LOGGING_PREFIX_SIZE];
    size_t size;
    ptr = wcsrchr(g_ExecutableName, '.');
    if (ptr)
       size = ptr - g_ExecutableName;
    else size = wcslen(g_ExecutableName);
    wcscpy(defaultLogFileName, g_ExecutableName);
    wcscpy(&defaultLogFileName[size], CX_SERVICE_LOGGING_EXTENSION);
    if (wcslen(gIniFileName) == 0) {
        wcscpy(gIniFileName, g_ExecutableName);
        wcscpy(&gIniFileName[size], CX_SERVICE_INI_EXTENSION);
    }
    logLevel = GetPrivateProfileIntW(CX_LOGGING_SECTION_NAME,
            CX_LOGGING_LEVEL_KEY, LOG_LEVEL_ERROR, gIniFileName);
    GetPrivateProfileStringW(CX_LOGGING_SECTION_NAME,
            CX_LOGGING_FILE_NAME_KEY, defaultLogFileName, logFileName,
            sizeof(logFileName), gIniFileName);
    maxFiles = GetPrivateProfileIntW(CX_LOGGING_SECTION_NAME,
            CX_LOGGING_MAX_FILES_KEY, 1, gIniFileName);
    maxFileSize = GetPrivateProfileIntW(CX_LOGGING_SECTION_NAME,
            CX_LOGGING_MAX_FILE_SIZE_KEY, DEFAULT_MAX_FILE_SIZE, gIniFileName);
    GetPrivateProfileStringW(CX_LOGGING_SECTION_NAME,
            CX_LOGGING_PREFIX_KEY, CX_LOGGING_PREFIX_DEFAULT, prefix,
            CX_LOGGING_PREFIX_SIZE, gIniFileName);
    return StartLoggingW(logFileName, logLevel, maxFiles, maxFileSize, prefix);
}
static int Service_StartLogging ( void ) { wchar_t defaultLogFileName [ PATH_MAX + 1 ] , logFileName [ PATH_MAX + 1 ] ; unsigned logLevel , maxFiles , maxFileSize ; wchar_t * ptr , prefix [ CX_LOGGING_PREFIX_SIZE ] ; size_t size ; ptr = wcsrchr ( g_ExecutableName , ' ' ) ; if ( ptr ) size = ptr - g_ExecutableName ; else size = wcslen ( g_ExecutableName ) ; wcscpy ( defaultLogFileName , g_ExecutableName ) ; wcscpy ( & defaultLogFileName [ size ] , CX_SERVICE_LOGGING_EXTENSION ) ; if ( wcslen ( gIniFileName ) == 0 ) { wcscpy ( gIniFileName , g_ExecutableName ) ; wcscpy ( & gIniFileName [ size ] , CX_SERVICE_INI_EXTENSION ) ; } logLevel = GetPrivateProfileIntW ( CX_LOGGING_SECTION_NAME , CX_LOGGING_LEVEL_KEY , LOG_LEVEL_ERROR , gIniFileName ) ; GetPrivateProfileStringW ( CX_LOGGING_SECTION_NAME , CX_LOGGING_FILE_NAME_KEY , defaultLogFileName , logFileName , sizeof ( logFileName ) , gIniFileName ) ; maxFiles = GetPrivateProfileIntW ( CX_LOGGING_SECTION_NAME , CX_LOGGING_MAX_FILES_KEY , 1 , gIniFileName ) ; maxFileSize = GetPrivateProfileIntW ( CX_LOGGING_SECTION_NAME , CX_LOGGING_MAX_FILE_SIZE_KEY , DEFAULT_MAX_FILE_SIZE , gIniFileName ) ; GetPrivateProfileStringW ( CX_LOGGING_SECTION_NAME , CX_LOGGING_PREFIX_KEY , CX_LOGGING_PREFIX_DEFAULT , prefix , CX_LOGGING_PREFIX_SIZE , gIniFileName ) ; return StartLoggingW ( logFileName , logLevel , maxFiles , maxFileSize , prefix ) ; }
Service_StartLogging()
Initialize logging for the service.
Service_StartLogging () Initialize logging for the service .
// determine the default log file name and ini file name // read the entries from the ini file // start the logging process