Ejemplo n.º 1
0
        public void SetLogFilterType(LogFilterType type)
        {
            switch (type)
            {
            case LogFilterType.NeverLog:
                this.filter = NeverLogFilter.GetInstance(this.logWriterFactory);
                break;

            case LogFilterType.AlwaysLog:
                this.filter = AlwaysLogFilter.GetInstance(this.logWriterFactory);
                break;

            case LogFilterType.Defogger:
                this.filter = DefoggerLogFilter.GetInstance(this.logWriterFactory, this.database);
                break;

            case LogFilterType.OpenLoop:
                this.filter = OpenLoopLogFilter.GetInstance(this.logWriterFactory, this.database);
                break;

            case LogFilterType.ClosedLoop:
                this.filter = ClosedLoopLogFilter.GetInstance(this.logWriterFactory, this.database);
                break;

            case LogFilterType.FullThrottle:
                this.filter = FullThrottleLogFilter.GetInstance(this.logWriterFactory, this.database);
                break;

            default:
                throw new InvalidOperationException("Undefined log filter type: " + type.ToString());
            }

            // Update the InternalLogProfile
            this.SetProfile(this.currentProfile);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Display the given log mode in the UI.
 /// </summary>
 /// <param name="mode">New logging mode.</param>
 void IUserInterface.SetLogFilterType(LogFilterType type)
 {
     if (type == LogFilterType.AlwaysLog)
     {
         this.logAlways.Checked = true;
     }
     else if (type == LogFilterType.NeverLog)
     {
         this.logOff.Checked = true;
     }
     else if (type == LogFilterType.Defogger)
     {
         this.logDefogger.Checked = true;
     }
     else if (type == LogFilterType.ClosedLoop)
     {
         this.logClosedLoop.Checked = true;
     }
     else if (type == LogFilterType.OpenLoop)
     {
         this.logOpenLoop.Checked = true;
     }
     else if (type == LogFilterType.FullThrottle)
     {
         this.logFullThrottle.Checked = true;
     }
     else
     {
         throw new NotImplementedException("Unsupported LogFilterType: " + type.ToString());
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Display a message in the logfile/message window.
        /// Will also be shown on the UI alert pane with the Alert/Error options
        /// </summary>
        /// <param name="text">Message to display</param>
        /// <param name="filter">The LogFilterType category of the log entry
        /// </param>
        /// <param name="graph">Graph this applies to. If aimed at a trace, just use any graph of the trace</param>
        /// <param name="trace">Process this applies to</param>

        public static void RecordLogEvent(string text, LogFilterType filter = LogFilterType.Info, ProtoGraph?graph = null, TraceRecord?trace = null)
        {
            TEXT_LOG_EVENT log = new TEXT_LOG_EVENT(filter: filter, text: text);

            if (graph != null)
            {
                log.SetAssociatedGraph(graph);
            }
            if (trace != null)
            {
                log.SetAssociatedTrace(trace);
            }

            lock (_messagesLock)
            {
                //write all logs to the logfile in bulk logging mode
                if (GlobalConfig.Settings.Logs.BulkLogging)
                {
                    try
                    {
                        WriteToDebugFile(log);
                    }
                    catch (Exception e)
                    {
                        GlobalConfig.Settings.Logs.BulkLogging = false;
                        Logging.RecordLogEvent($"Error: Not able to write to bulk log file {e.Message}. Another rgat may be using it. Disabling bulk logging.");
                    }
                }

                //write non-bulklog files to the UI log pane
                if (filter != LogFilterType.BulkDebugLogFile)
                {
                    _logMessages.Add(log);
                    if (log.Filter == LogFilterType.Alert || log.Filter == LogFilterType.Error)
                    {
                        UnseenAlerts += 1;
                        _alertNotifications.Add(log);
                        _lastAlert = DateTime.Now;
                    }
                    MessageCounts[(int)filter] += 1;
                }
            }

            //todo remove after debug done
            if (filter == LogFilterType.Error)
            {
                WriteConsole(text, ConsoleColor.Yellow);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Callback to be invoked when the ECU connection is established.
        /// </summary>
        /// <param name="asyncResult">Async result.</param>
        private void ConnectCallback(IAsyncResult asyncResult)
        {
            Trace("Lumberjack.ConnectCallback");

            if (this.logger == null)
            {
                return;
            }

            Exception exception = null;

            try
            {
                this.ssmParameterSource = this.logger.EndConnect(asyncResult);
                this.database.Add(this.ssmParameterSource);
            }
            catch (IOException ex)
            {
                exception = ex;
            }
            catch (UnauthorizedAccessException ex)
            {
                exception = ex;
            }

            if (exception != null)
            {
                this.ui.Invoke(new ThreadStart(
                                   delegate
                {
                    this.ui.RenderError(exception);
                    this.ui.ConnectionStateChanged(false);
                }));
                return;
            }

            try
            {
                this.ui.Invoke(new ThreadStart(
                                   delegate
                {
                    this.ui.PopulateParameterList(this.database);
                    this.ui.ConnectionStateChanged(true);

                    this.LoadSelectedProfile();

                    this.Settings.DefaultSsmPort = (string)asyncResult.AsyncState;
                    this.Settings.Save();
                    this.currentProfileIsChanged = false;

                    LogFilterType filterType = this.ui.GetLogFilterType();
                    this.SetLogFilterType(filterType);
                }));
            }
            catch (IOException ex)
            {
                this.ui.Invoke(new ThreadStart(
                                   delegate
                {
                    this.ui.RenderError(ex);
                }));
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Set the current logging mode.
 /// </summary>
 /// <param name="value">Desired logging mode.</param>
 public void SetLogFilterType(LogFilterType type)
 {
     this.logger.SetLogFilterType(type);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Set the logging mode to use upon startup.
 /// </summary>
 /// <param name="value">Logging mode to use upon start.</param>
 public void SetStartupLogFilterType(LogFilterType value)
 {
     this.startMode = value;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Create a text log event
 /// </summary>
 /// <param name="filter">How this log is handled</param>
 /// <param name="text">The log entry</param>
 public TEXT_LOG_EVENT(LogFilterType filter, string text) : base(eLogFilterBaseType.Text)
 {
     Text   = text;
     Filter = filter;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Set the logging mode to use upon startup.
 /// </summary>
 /// <param name="value">Logging mode to use upon start.</param>
 public void SetStartMode(LogFilterType type)
 {
     this.lumberjack.SetStartupLogFilterType(type);
 }
Ejemplo n.º 9
0
 public void SetLogFilterType(LogFilterType type)
 {
     this.RecordEvent("SetLogFilterType: " + type.ToString());
 }
Ejemplo n.º 10
0
 public void SetLogMode(LogFilterType mode)
 {
     this.RecordEvent("SetLogMode: " + mode.ToString());
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Filter v7 log lines by index.  Has no effect on legacy log lines.
        /// </summary>
        public static IEnumerable<LogLine> Filter(this IEnumerable<LogLine> logLines, LogFilterType filterType, int index)
        {
            if (logLines == null) throw new ArgumentNullException("logLines");

             switch (filterType)
             {
            case LogFilterType.UnitIndex:
               return FilterUnitIndex(logLines, index);
            case LogFilterType.UnitAndNonIndexed:
               return FilterUnitAndNonIndexed(logLines, index);
            case LogFilterType.SlotIndex:
               return FilterSlotIndex(logLines, index);
            case LogFilterType.SlotAndNonIndexed:
               return FilterSlotAndNonIndexed(logLines, index);
            default:
               return logLines;
             }
        }
 public FilterNotSupportedException(LogFilterType filterType, Type storeType)
     : base(string.Format("The filter type of {0} is not supported by the {1} log record store", filterType.ToString(), storeType.Name))
 {
     FilterType = filterType;
     StoreType = storeType;
 }