示例#1
0
        /// <summary>
        /// Get the name of the innermost directory name for configurations for the part of FLEx the user is
        /// working in, such as Dictionary or Reversal Index.
        /// </summary>
        private static string GetInnermostConfigurationDirectory(IPropertyRetriever propertyTable)
        {
            switch (propertyTable.GetStringProperty("currentContentControl", null))
            {
            case "reversalToolBulkEditReversalEntries":
            case "reversalToolEditComplete":
                return(ReversalIndexConfigurationDirectoryName);

            case "lexiconBrowse":
            case "lexiconDictionary":
            case "lexiconEdit":
                return(DictionaryConfigurationDirectoryName);

            default:
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// Get the base (non-localized) name of the area in FLEx being configured, such as Dictionary or Reversal Index.
        /// </summary>
        internal static string GetDictionaryConfigurationBaseType(IPropertyRetriever propertyTable)
        {
            var toolName = propertyTable.GetStringProperty("currentContentControl", null);

            switch (toolName)
            {
            case "reversalToolBulkEditReversalEntries":
            case "reversalToolEditComplete":
                return("Reversal Index");

            case "lexiconBrowse":
            case "lexiconDictionary":
            case "lexiconEdit":
                return("Dictionary");

            default:
                return(null);
            }
        }
        public static LoggerConfiguration GetLoggerConfiguration(
            NanoLoggerManager manager,
            IPropertyRetriever propertyRetriever,
            bool withDefaultConsoleLog = false)
        {
            var logger = new LoggerConfiguration()
                         .Enrich.WithExceptionDetails()
                         .Enrich.WithMachineName()
                         .Enrich.WithEnvironmentUserName()
                         .Enrich.WithProcessId()
                         .Enrich.WithThreadId()
                         .Enrich.WithLoggerLevel()
                         .MinimumLevel.Verbose();

            logger = logger
                     .WithSeqLog(manager, propertyRetriever)
                     .WithFileLog(manager, propertyRetriever)
                     .WithConsoleLog(manager, propertyRetriever, withDefaultConsoleLog);

            return(logger);
        }
示例#4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determine a stylesheet from a PropertyTable. Currently this is done by looking for the main window
        /// and seeing whether it has a StyleSheet property that returns one. (We use reflection
        /// because the relevant classes are in DLLs we can't reference.)
        /// </summary>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public static LcmStyleSheet StyleSheetFromPropertyTable(IPropertyRetriever propertyTable)
        {
            Form         mainWindow = propertyTable.GetValue <Form>("window");
            PropertyInfo pi         = null;

            if (mainWindow != null)
            {
                string areaChoice = propertyTable.GetStringProperty("areaChoice", null);
                if (areaChoice != null && areaChoice.ToLowerInvariant() == "notebook")
                {
                    pi = mainWindow.GetType().GetProperty("AnthroStyleSheet");
                }
                if (pi == null)
                {
                    pi = mainWindow.GetType().GetProperty("StyleSheet");
                }
            }
            if (pi != null)
            {
                return(pi.GetValue(mainWindow, null) as LcmStyleSheet);
            }
            return(propertyTable.GetValue <LcmStyleSheet>("LcmStyleSheet"));
        }
        public static LoggerConfiguration WithConsoleLog(this LoggerConfiguration logger, NanoLoggerManager manager, IPropertyRetriever propertyRetriever, bool withDefaultConsoleLog = false)
        {
            if (withDefaultConsoleLog)
            {
                logger = logger
                         .WriteTo.Console(
                    outputTemplate: "{Timestamp} [{ColoredLogLevel}] (MachineName: {MachineName}) (Thread: {ThreadId}) {Message} {Exception}{NewLine}",
                    levelSwitch: new LoggingLevelSwitch());
            }
            else
            {
                var withConsoleLog = propertyRetriever.CheckFromCommandLine("withConsoleLog");

                if (withConsoleLog)
                {
                    var consoleMessageTemplate = propertyRetriever.RetrieveFromCommandLineOrEnvironment("consoleMessageTemplate", "consoleMessageTemplate", "{Timestamp} [{LogLevel}] (MachineName: {MachineName}) (Thread: {ThreadId}) {Message} {Exception}{NewLine}").Replace("{LogLevel}", "{ColoredLogLevel}");
                    manager.SetConsoleLoggingLevel(propertyRetriever.RetrieveFromCommandLineOrEnvironment("consoleMinimumLogEventLevel", "consoleMinimumLogEventLevel", LogLevel.None));
                    logger = logger
                             .WriteTo.Console(
                        outputTemplate: consoleMessageTemplate,
                        levelSwitch: manager.ConsoleLoggingLevelSwitch);
                }
            }

            return(logger);
        }
        public static LoggerConfiguration WithFileLog(this LoggerConfiguration logger, NanoLoggerManager manager, IPropertyRetriever propertyRetriever)
        {
            var withFileLog = propertyRetriever.CheckFromCommandLine("withFileLog");

            if (withFileLog)
            {
                var fileMessageTemplate = propertyRetriever.RetrieveFromCommandLineOrEnvironment("fileMessageTemplate", "fileMessageTemplate", "{Timestamp} [{LogLevel}] (MachineName: {MachineName}) (Thread: {ThreadId}) {Message} {Exception}{NewLine}");
                var fileRollingInterval = propertyRetriever.RetrieveFromCommandLineOrEnvironment("fileRollingInterval", "fileRollingInterval", RollingInterval.Hour);
                manager.SetFileLoggingLevel(propertyRetriever.RetrieveFromCommandLineOrEnvironment("fileMinimumLogEventLevel", "fileMinimumLogEventLevel", LogLevel.None));

                logger = logger
                         .WriteTo.File(
                    path: $"log\\log_{propertyRetriever.RetrieveServiceName()}_.txt",
                    levelSwitch: manager.FileLoggingLevelSwitch,
                    rollingInterval: fileRollingInterval,
                    outputTemplate: fileMessageTemplate,
                    shared: true);
            }

            return(logger);
        }
        public static LoggerConfiguration WithSeqLog(this LoggerConfiguration logger, NanoLoggerManager manager, IPropertyRetriever propertyRetriever)
        {
            var withSeqLog = propertyRetriever.CheckFromCommandLine("withSeqLog");

            if (withSeqLog)
            {
                var seqAddress = propertyRetriever.RetrieveFromCommandLineOrEnvironment("seqLogAddress", "seqLogAddress", null);
                var seqApiKey  = propertyRetriever.RetrieveFromCommandLineOrEnvironment("seqApiKey", "seqApiKey", null);
                manager.SetSeqLoggingLevel(propertyRetriever.RetrieveFromCommandLineOrEnvironment("seqMinimumLogEventLevel", "seqMinimumLogEventLevel", LogLevel.None));

                logger = logger
                         .WriteTo.Seq(
                    serverUrl: seqAddress,
                    apiKey: seqApiKey,
                    controlLevelSwitch: manager.SeqLoggingLevelSwitch);
            }

            return(logger);
        }