private BMyLog4PB NewLog()
            {
                if (App == null || GlobalArgs == null)
                {
                    return(null);
                }

                BMyLog4PB TempLogger;
                string    verbosity = GlobalArgs.getOption("LogLevel")[0]?.Trim() ?? "error";

                if (verbosity.Equals("OFF"))
                {
                    TempLogger = null;
                }
                else
                {
                    TempLogger = new BMyLog4PB(this.App);
                    switch (verbosity)
                    {
                    case "trace":
                        TempLogger.Filter = BMyLog4PB.E_TRACE | BMyLog4PB.E_DEBUG | BMyLog4PB.E_INFO | BMyLog4PB.E_WARN | BMyLog4PB.E_ERROR | BMyLog4PB.E_FATAL;
                        break;

                    case "debug":
                        TempLogger.Filter = BMyLog4PB.E_DEBUG | BMyLog4PB.E_INFO | BMyLog4PB.E_WARN | BMyLog4PB.E_ERROR | BMyLog4PB.E_FATAL;
                        break;

                    case "info":
                        TempLogger.Filter = BMyLog4PB.E_INFO | BMyLog4PB.E_WARN | BMyLog4PB.E_ERROR | BMyLog4PB.E_FATAL;
                        break;

                    case "warn":
                        TempLogger.Filter = BMyLog4PB.E_WARN | BMyLog4PB.E_ERROR | BMyLog4PB.E_FATAL;
                        break;

                    case "error":
                        TempLogger.Filter = BMyLog4PB.E_ERROR | BMyLog4PB.E_FATAL;
                        break;

                    case "fatal":
                        TempLogger.Filter = BMyLog4PB.E_FATAL;
                        break;

                    default:
                        TempLogger.Filter = BMyLog4PB.E_ERROR | BMyLog4PB.E_FATAL;
                        break;
                    }
                    foreach (KeyValuePair <string, string> logMsg in LogMessages)
                    {
                        TempLogger.SetMessage(logMsg.Key, logMsg.Value);
                    }

                    TempLogger.AutoFlush = true;
                    TempLogger.AddAppender(new BMyLog4PB.BMyTextPanelAppender(GlobalArgs.getOption("LogLCD")[0]?.Trim() ?? "[BCC-LOG]", App));
                    TempLogger.Info("L1");
                }
                return(TempLogger);
            }
Beispiel #2
0
        private void BootstrapLog(BaconArgs Args)
        {
            Log = new BMyLog4PB(this, 0);
            if (!Args.hasOption("log-noecho"))
            {
                Log?.AddAppender(new BMyLog4PB.BMyEchoAppender(this));
            }
            if (Args.hasOption("log-lcd"))
            {
                string logLcdTag = Args.getOption("log-lcd")[0];
                if (logLcdTag != null)
                {
                    Log?.AddAppender(new BMyLog4PB.BMyTextPanelAppender(logLcdTag, this));
                }
            }
            if (Args.hasOption("log-filter") && Args.getOption("log-filter").Count > 0)
            {
                log_Filter = 0;
                foreach (string filterArgValue in Args.getOption("log-filter"))
                {
                    string[] filterList = filterArgValue.ToLowerInvariant().Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string filter in filterList)
                    {
                        switch (filter)
                        {
                        case "trace":
                            log_Filter |= BMyLog4PB.E_TRACE;
                            break;

                        case "debug":
                            log_Filter |= BMyLog4PB.E_DEBUG;
                            break;

                        case "info":
                            log_Filter |= BMyLog4PB.E_INFO;
                            break;

                        case "warn":
                            log_Filter |= BMyLog4PB.E_WARN;
                            break;

                        case "error":
                            log_Filter |= BMyLog4PB.E_ERROR;
                            break;

                        case "fatal":
                            log_Filter |= BMyLog4PB.E_FATAL;
                            break;

                        case "all":
                            log_Filter |= BMyLog4PB.E_ALL;
                            break;
                        }
                    }
                }
            }
            if (Log != null)
            {
                Log.Filter = log_Filter;
            }
        }