示例#1
0
   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_);
   }
示例#2
0
static const char*
getURL( const char *name )
{
    int len = 0;
    char* buff = NULL;
    const char* property = NULL;
    
    if (name == NULL)
        return NULL;

    mama_log (MAMA_LOG_LEVEL_FINE, "initializing Avis transport: %s", name);
    len = strlen(name) + strlen( TPORT_PREFIX ) + strlen(TPORT_PARAM) + 4;
    buff = (char *)alloca( len );
    memset(buff, '\0', len);
    snprintf( buff, len, "%s.%s.%s", TPORT_PREFIX, name, TPORT_PARAM );

    property = properties_Get( mamaInternal_getProperties(), buff );
    if ( property == NULL )
      return DEFAULT_URL;

    mama_log (MAMA_LOG_LEVEL_FINER,
              "Avis transport (%s) main connection: %s", name, property);
    return property;
}
示例#3
0
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);
	}    
}