/// <summary> /// Constructor /// </summary> /// <param name="config"> /// A config instance whose value members must be copied into this /// instance (deep copy) /// </param> protected LogConfig(LogConfig config) { // Create deep copy m_autoStart = config.m_autoStart; m_autoFlushPeriodicTime = config.m_autoFlushPeriodicTime; m_autoFlushStartupTime = config.m_autoFlushStartupTime; m_cleanupLogs = config.m_cleanupLogs; m_cleanupMessages = config.m_cleanupMessages; m_cleanupResources = config.m_cleanupResources; m_cleanupSessions = config.m_cleanupSessions; m_folder = config.m_folder; m_folderPath = config.m_folderPath; m_globalLevels = config.m_globalLevels; m_globalTrace = config.m_globalTrace; m_formattersObject = config.m_formattersObject.Clone(); m_formattersException = config.m_formattersException.Clone(); m_defaultEntry = config.m_defaultEntry.Clone(); // Create deep copy of entries collection m_listEntries = new List <LogConfigEntry>(); foreach (var entry in config.m_listEntries) { m_listEntries.Add((LogConfigEntry)entry.Clone()); } // Create deep copy of monitors collection m_listMonitors = new List <LogConfigMonitorType>(); foreach (var monitor in config.m_listMonitors) { m_listMonitors.Add((LogConfigMonitorType)monitor.Clone()); } }
/// <summary> /// Constructor /// </summary> /// <param name="defaultEntry"> /// A LogConfigDefaultEntry instance whose value members must be copied into /// this instance (deep copy) /// </param> protected LogConfigDefaultEntry(LogConfigDefaultEntry defaultEntry) { // Deep copy members m_id = defaultEntry.m_id; m_localEnabledLevels = defaultEntry.m_localEnabledLevels; m_localTrace = defaultEntry.m_localTrace; // Create deep copy of streamers collection m_listTypes = new List <LogConfigStreamerType>(); foreach (var streamerType in defaultEntry.m_listTypes) { m_listTypes.Add(streamerType.Clone()); } }
// ****************************************************************** // * * // * Constructors * // * * // ****************************************************************** /// <summary> /// Constructor /// </summary> public LogConfig() { // Set members to default m_autoStart = DEFAULT_AUTOSTART; m_autoFlushPeriodicTime = DEFAULT_AUTOFLUSHPERIODICTIME; m_autoFlushStartupTime = DEFAULT_AUTOFLUSHSTARTUPTIME; m_cleanupLogs = DEFAULT_CLEANUPLOGS; m_cleanupMessages = DEFAULT_CLEANUPMESSAGES; m_cleanupResources = DEFAULT_CLEANUPRESOURCES; m_cleanupSessions = DEFAULT_CLEANUPSESSIONS; m_folder = DEFAULT_FOLDER; m_folderPath = DEFAULT_FOLDERPATH; m_globalLevels = DEFAULT_GLOBALLEVELS; m_globalTrace = DEFAULT_GLOBALTRACE; m_listEntries = new List <LogConfigEntry>(); m_listMonitors = new List <LogConfigMonitorType>(); m_formattersObject = new LogConfigFormatterProvider <object>(); m_formattersException = new LogConfigFormatterProvider <Exception>(); m_defaultEntry = CreateDefaultEntry(); }
// ****************************************************************** // * * // * Protected Methods * // * * // ****************************************************************** /// <summary> /// Creates and initializes a new set of ILogStreamer instances /// </summary> /// <param name="message"> /// A LogMessage instance for which a new set of streamer instances must be created /// </param> /// <returns> /// An array that holds a set of new ILogStreamer instances /// </returns> protected ILogStreamer[] CreateAndInitializeStreamers(LogMessage message) { // Resolve configuration entry for this log LogConfigDefaultEntry entry = m_sessionConfig.DefaultEntry; LogConfigEntry configEntry; if (m_sessionConfig.TryGetEntryById(message.ConfigEntryId, out configEntry)) { entry = configEntry; } // Create streamer instances ILogStreamer[] streamers; IParameterDictionary[] parameters; entry.CreateStreamers(out streamers, out parameters); // Count concurrent streamer types var dicConcurrentTypesCount = new Dictionary <Type, int>(); var lstConcurrentTypesIndex = new List <int>(); for (int i = 0; i < streamers.Length; i++) { // Did we already encountered this type? int count; var type = streamers[i].GetType(); if (dicConcurrentTypesCount.TryGetValue(type, out count)) { dicConcurrentTypesCount[type] = count + 1; lstConcurrentTypesIndex.Add(count + 1); } else { dicConcurrentTypesCount[type] = 1; lstConcurrentTypesIndex.Add(1); } } // Modify config in case we are working with stream for logmanager // This is a special case where we DO NOT want to apply cleanup. // We want to ensure that all messages are kept to enable reading! var config = m_sessionConfig; if (message.LogName == LogManager.LOGNAME_LOGMANAGER) { // Create copy of config and config = m_sessionConfig.Clone(); config.CleanupMessages = -1; } // Initialize streamers for (int i = 0; i < streamers.Length; i++) { streamers[i].Init(new LogStreamerInitArgs( m_sessionGuid, m_sessionFolderFullName, m_sessionResourceFolderFullName, config, parameters[i], message.LogName, dicConcurrentTypesCount[streamers[i].GetType()], lstConcurrentTypesIndex[i])); } // Return references return(streamers); }