Esempio n. 1
0
 private static void PrintLog(LogInfo logInfo)
 {
     Console.WriteLine("{0} from '{1}': Message: {2}", logInfo.Level, logInfo.SourceName, logInfo.Message);
     if (logInfo.Exception != null)
     {
         Console.WriteLine(logInfo.Exception.ToString());
     }
 }
        internal void Write(NLog.LogEventInfo logEvent)
        {
            string logEventLoggerFullName = logEvent.LoggerName;

            //filtered events, and add to events only these events coming from experiment of this logViewModel, or from TraceLab application
            if (logEventLoggerFullName.StartsWith("TraceLab") || logEventLoggerFullName.StartsWith(ExperimentId))
            {
                string userFriendlySource;

                LogInfo info;
                if (logEventLoggerFullName.StartsWith("TraceLab"))
                {
                    userFriendlySource = logEventLoggerFullName;
                    info = new LogInfo { SourceName = userFriendlySource, Source = logEventLoggerFullName, Level = logEvent.Level, Message = logEvent.FormattedMessage, Exception = logEvent.Exception };
                }
                else
                {
                    string sourceAssembly, componentName;
                    TraceLab.Core.Components.LoggerFactory.ExtractLogSourceInfo(logEventLoggerFullName, out componentName, out sourceAssembly, out userFriendlySource);
                    info = new ComponentLogInfo
                    {
                        SourceName = userFriendlySource,
                        Source = logEventLoggerFullName,
                        Level = logEvent.Level,
                        Message = logEvent.FormattedMessage,
                        Exception = logEvent.Exception,
                        ComponentName = componentName,
                        AssemblySource = sourceAssembly
                    };

                    if (logEvent.Exception != null)
                    {
                        System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(logEvent.Exception);
                    }
                }   
                
                m_events.Add(info);
            }
        }
        /// <summary>
        /// Adds the event unit to the log store
        /// </summary>
        /// <param name='logInfo'>
        /// Log info.
        /// </param>
        private void AddEventUnit(LogInfo logInfo) 
        {
            Gdk.Pixbuf icon;
            
            if(logInfo.Level == NLog.LogLevel.Info)
                icon = m_iconInfo;
            else if(logInfo.Level == NLog.LogLevel.Trace) 
                icon = m_iconTrace;
            else if(logInfo.Level == NLog.LogLevel.Debug)
                icon = m_iconDebug;
            else if(logInfo.Level == NLog.LogLevel.Warn)
                icon = m_iconWarning;
            else if(logInfo.Level == NLog.LogLevel.Error) 
                icon = m_iconError;
            else 
                icon = m_iconError; //in case it is LogLevel.Fatal

            m_logStore.AppendValues(icon, logInfo.Level.ToString(), logInfo.SourceName, logInfo.Message);
        }
 private void RemoveUnit(LogInfo unit)
 {
     Dispatch.Invoke(new Action(() => m_units.Remove(unit)),
                     DispatcherPriority.Send);
 }
 private void InsertUnit(LogInfo unit, int index)
 {
     Dispatch.Invoke(new Action(() => m_units.Insert(index, unit)),
                     DispatcherPriority.Send);
 }
 private void AddUnit(LogInfo unit)
 {
     Dispatch.Invoke(new Action(() => m_units.Add(unit)),
                     DispatcherPriority.Send);
 }