CTick42Logger::CTick42Logger(const char *filename, size_t lineNumber, MamaLogLevel logLevel) : filename_(filename) , lineNumber_(lineNumber) , logLevel_(logLevel) { // Initialize the statics, if we haven't already done so if (!once_) { once_ = true; const char *val = properties_Get(mamaInternal_getProperties(), "mama.logging.level"); if ((val == 0) || (mama_tryStringToLogLevel(val, &maxLogLevel_) == 0)) { maxLogLevel_ = MAMA_LOG_LEVEL_OFF; } val = properties_Get(mamaInternal_getProperties(), "mama.tick42rmds.consolelogging"); logConsole_ = (0 != val) ? (0 != properties_GetPropertyValueAsBoolean(val)) : false; #ifdef _WIN32 // Do we log to the system debugger instead of the mama log file? val = properties_Get(mamaInternal_getProperties(), "mama.tick42rmds.ODSloggingOnly"); logODS_ = (0 != val) ? (0 != properties_GetPropertyValueAsBoolean(val)) : false; #endif } enabled_ = (MAMA_LOG_LEVEL_OFF != maxLogLevel_) && (logLevel <= maxLogLevel_); }
void mama_loginit(void) { /* Acquire the write lock. */ MRSW_RESULT al = mamaLog_acquireLock(0); if(MRSW_S_OK == al) { /* Find out if milliseconds should be written, this must be done first before any logs are * written. */ const char *propstring = properties_Get(mamaInternal_getProperties(), MAMALOG_MILLISECONDS_PROPERTY_NAME); if (propstring) { g_milliseconds = properties_GetPropertyValueAsBoolean(propstring); } propstring = properties_Get(mamaInternal_getProperties(), LEVELPROPERTY); if (propstring) { MamaLogLevel level = MAMA_LOG_LEVEL_OFF; if (1 == mama_tryStringToLogLevel(propstring, &level)) { gMamaLogLevel = level; } else { mama_log (MAMA_LOG_LEVEL_WARN, "%s=%s not recognised. Using default.", LEVELPROPERTY, propstring); } } propstring = properties_Get(mamaInternal_getProperties(), POLICYPROPERTY); if (propstring) { if (0 == strcasecmp(propstring,"ROLL")) { g_logFilePolicy = LOGFILE_ROLL; } else if (0 == strcasecmp(propstring,"OVERWRITE")) { g_logFilePolicy = LOGFILE_OVERWRITE; } else if (0 == strcasecmp(propstring,"USER")) { g_logFilePolicy = LOGFILE_USER; } else { g_logFilePolicy = LOGFILE_UNBOUNDED; } } propstring = properties_Get(mamaInternal_getProperties(), FILESIZEPROPERTY); if (propstring) { g_maxLogSize = atoi(propstring); } propstring = properties_Get(mamaInternal_getProperties(), ROLLPROPERTY); if (propstring) { numRolledLogfiles = atoi(propstring); } propstring = properties_Get(mamaInternal_getProperties(), APPENDPROPERTY); if (propstring) { appendToFile = properties_GetPropertyValueAsBoolean(propstring); } propstring = properties_Get(mamaInternal_getProperties(), FILENAMEPROPERTY); if (propstring) { mama_logToFile (propstring, gMamaLogLevel); } /* Release the write lock. */ MRSWLock_release(g_lock, 0); } }