public void WriteEntry(string entry, LoggingLevel level = LoggingLevel.Error, int updateId = -1)
        {
            if (Level <= level)
            {
                if(updateId > 0)//to drop each update in a single file
                    File.AppendAllLines(_fileName + updateId, new List<string> { $"{DateTime.Now.ToString("s")}|{level.ToString().ToUpper()}|{entry}" });
                else
                    File.AppendAllLines(_fileName, new List<string> { $"{DateTime.Now.ToString("s")}|{level.ToString().ToUpper()}|{entry}" });

                Console.WriteLine($"{DateTime.Now.ToString("s")}|{level.ToString().ToUpper()}|{entry}");
            }
        }
Ejemplo n.º 2
0
 static void log(LoggingLevel level, string message)
 {
     if (Level <= level)
     {
         Console.Error.WriteLine($"[{level.ToString()}]\t{DateTime.Now:u}\t{message}");
     }
 }
Ejemplo n.º 3
0
        public void Write(LoggingLevel level, string format, params object[] args)
        {
            Console.Write(level.ToString().ToUpper());
            Console.Write("[" + DateTime.Now.ToString() + "]");
            Console.Write(": ");
            Console.WriteLine(format, args);

            var message = string.Format(format, args);

            switch (level)
            {
            case LoggingLevel.Debug:
                log.Debug(message);
                break;

            case LoggingLevel.Information:
                log.Info(message);
                break;

            case LoggingLevel.Warning:
                log.Warn(message);
                break;

            case LoggingLevel.Error:
                log.Error(message);
                break;
            }
        }
Ejemplo n.º 4
0
        private static void LogToFileLog(String message, LoggingLevel level)
        {
            try
            {
                UpdateLogFile();

                // Write to file and Output (Default listener) if Debug
                String dateAndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                String logMessage  = String.Format("{0} [{1}] {2}", dateAndTime, level.ToString(), message);

                if (System.Diagnostics.Debugger.IsAttached)
                {
                    Trace.WriteLine(logMessage);
                }
                if (logListener != null)
                {
                    logListener.WriteLine(logMessage);
                    logListener.Flush();
                }
            }
            catch (Exception)
            {
                // Logging should not throw exception
            }
        }
Ejemplo n.º 5
0
        public void Log(LoggingLevel level, string message, DateTime time)
        {
            if (!Framework.Settings.LoggingSettings.LogToFile)
            {
                return;
            }

            if (Framework.Settings.LoggingSettings.LowestLoggingLevel > level)
            {
                return;
            }

            if (!File.Exists(LogFilePath))
            {
                throw new OMODFrameworkException($"FileLogger file at {LogFilePath} does not exist anymore!");
            }

            var msg = $"[{time:HH:mm:ss:fff}][{level.ToString()}]: {message}";

            try
            {
                File.AppendAllText(LogFilePath, $"\n{msg}", Encoding.UTF8);
            }
            catch (Exception e)
            {
                throw new OMODFrameworkException($"Could not write to file {LogFilePath}\n{e}");
            }
        }
Ejemplo n.º 6
0
        public void StoreValues(Data data, string path)
        {
            Accounts.StoreValues(data, path + @"Accounts\");
            JobHistory.StoreValues(data, path + @"JobHistory\");

            for (int i = 0; i < PrinterMappings.Count; i++)
            {
                PrinterMapping tmp = PrinterMappings[i];
                tmp.StoreValues(data, @"" + path + @"PrinterMappings\" + i + @"\");
            }
            data.SetValue(@"" + path + @"PrinterMappings\numClasses", PrinterMappings.Count.ToString());

            RssFeed.StoreValues(data, path + @"RssFeed\");

            for (int i = 0; i < TitleReplacement.Count; i++)
            {
                TitleReplacement tmp = TitleReplacement[i];
                tmp.StoreValues(data, @"" + path + @"TitleReplacement\" + i + @"\");
            }
            data.SetValue(@"" + path + @"TitleReplacement\numClasses", TitleReplacement.Count.ToString());

            UsageStatistics.StoreValues(data, path + @"UsageStatistics\");
            data.SetValue(@"" + path + @"ConversionTimeout", ConversionTimeout.ToString(System.Globalization.CultureInfo.InvariantCulture));
            data.SetValue(@"" + path + @"EnableTips", EnableTips.ToString());
            data.SetValue(@"" + path + @"Language", Data.EscapeString(Language));
            data.SetValue(@"" + path + @"LicenseExpirationReminder", LicenseExpirationReminder.ToString("yyyy-MM-dd HH:mm:ss"));
            data.SetValue(@"" + path + @"LoggingLevel", LoggingLevel.ToString());
            data.SetValue(@"" + path + @"NextUpdate", NextUpdate.ToString("yyyy-MM-dd HH:mm:ss"));
            data.SetValue(@"" + path + @"UnitOfMeasurement", UnitOfMeasurement.ToString());
            data.SetValue(@"" + path + @"UpdateInterval", UpdateInterval.ToString());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Logs a message
        /// </summary>
        /// <param name="level">The logging level</param>
        /// <param name="format">The format of the output</param>
        /// <param name="args">The format representation arguemtns</param>
        public void Log(LoggingLevel level, string format, params object[] args)
        {
            switch (level)
            {
            case LoggingLevel.Trace:
                Console.ForegroundColor = ConsoleColor.White;
                break;

            case LoggingLevel.Debug:
                Console.ForegroundColor = ConsoleColor.Gray;
                break;

            case LoggingLevel.Information:
                Console.ForegroundColor = ConsoleColor.Cyan;
                break;

            case LoggingLevel.Warning:
                Console.ForegroundColor = ConsoleColor.Yellow;
                break;

            case LoggingLevel.Error:
                Console.ForegroundColor = ConsoleColor.Red;
                break;

            case LoggingLevel.Fatal:
                Console.ForegroundColor = ConsoleColor.DarkRed;
                break;
            }

            WriteToStreams("[{0}][{1}] ", DateTime.Now.ToString("%H:%M:%s"), level.ToString());
            Console.ForegroundColor = ConsoleColor.White;

            WriteToStreams(format + '\n', args);
        }
Ejemplo n.º 8
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("[Accounts]");
            sb.AppendLine(Accounts.ToString());

            for (int i = 0; i < PrinterMappings.Count; i++)
            {
                sb.AppendLine(PrinterMappings.ToString());
            }


            for (int i = 0; i < TitleReplacement.Count; i++)
            {
                sb.AppendLine(TitleReplacement.ToString());
            }

            sb.AppendLine("AskSwitchDefaultPrinter=" + AskSwitchDefaultPrinter.ToString());
            sb.AppendLine("Language=" + Language.ToString());
            sb.AppendLine("LastUsedProfileGuid=" + LastUsedProfileGuid.ToString());
            sb.AppendLine("LoggingLevel=" + LoggingLevel.ToString());
            sb.AppendLine("PrimaryPrinter=" + PrimaryPrinter.ToString());
            sb.AppendLine("UpdateInterval=" + UpdateInterval.ToString());

            return(sb.ToString());
        }
        private void InternalLog(LoggingLevel level, Func <string> messageGenerator, Exception exc = null, Action <ILogContext> extraInfo = null)
        {
            string str = $"{DateTime.UtcNow.ToString()} [{level.ToString()}] {messageGenerator()}";

            if (exc != null)
            {
                str += Environment.NewLine;
                str += exc.Message + Environment.NewLine + Environment.NewLine;
                str += exc.StackTrace;
            }

            if (extraInfo != null)
            {
                LogContext lc = new LogContext();

                try
                {
                    str += Environment.NewLine;
                    extraInfo(lc);
                    str += lc.Format();
                }
                catch
                {
                    // TODO: Do something with this!
                }
            }

            str += Environment.NewLine;

            var writeTask = FileIO.AppendTextAsync(this.File, str, Windows.Storage.Streams.UnicodeEncoding.Utf8).AsTask();

            writeTask.Wait(1000);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Logs to <see cref="Constants.ETWChannelName"/> and either to <see cref="Debug.WriteLine"/> or <see cref="CustomLog"/>
        /// </summary>
        public static void Log(string message, LoggingLevel level)
        {
            /*
             *  You can collect the events generated by this method with xperf or another
             *  ETL controller tool. To collect these events in an ETL file:
             *
             *  xperf -start MySession -f MyFile.etl -on Constants.ETWGuid
             *  (call LogError())
             *  xperf -stop MySession
             *
             *  After collecting the ETL file, you can decode the trace using xperf, wpa,
             *  or tracerpt. For example, to decode MyFile.etl with tracerpt:
             *
             *  tracerpt MyFile.etl
             *  (generates dumpfile.xml)
             */

            using (var channel = new LoggingChannel(Constants.ETWChannelName, null /*default options*/, new Guid(Constants.ETWGuid)))
            {
                channel.LogMessage(message, level);
            }

            if (CustomLog != null)
            {
                CustomLog(message, level);
            }
            else
            {
                Debug.WriteLine("[" + Constants.ETWChannelName + "]    [" + level.ToString() + "]    " + message);
            }
        }
Ejemplo n.º 11
0
        public void StoreValues(Data data, string path)
        {
            for (var i = 0; i < ApiAccess.Count; i++)
            {
                var tmp = ApiAccess[i];
                tmp.StoreValues(data, @"" + path + @"ApiAccess\" + i + @"\");
            }

            data.SetValue(@"" + path + @"ApiAccess\numClasses", ApiAccess.Count.ToString());

            for (var i = 0; i < PrinterMappings.Count; i++)
            {
                var tmp = PrinterMappings[i];
                tmp.StoreValues(data, @"" + path + @"PrinterMappings\" + i + @"\");
            }

            data.SetValue(@"" + path + @"PrinterMappings\numClasses", PrinterMappings.Count.ToString());

            for (var i = 0; i < TitleReplacement.Count; i++)
            {
                var tmp = TitleReplacement[i];
                tmp.StoreValues(data, @"" + path + @"TitleReplacement\" + i + @"\");
            }

            data.SetValue(@"" + path + @"TitleReplacement\numClasses", TitleReplacement.Count.ToString());

            data.SetValue(@"" + path + @"AskSwitchDefaultPrinter", AskSwitchDefaultPrinter.ToString());
            data.SetValue(@"" + path + @"Language", Data.EscapeString(Language));
            data.SetValue(@"" + path + @"LastUsedProfileGuid", Data.EscapeString(LastUsedProfileGuid));
            data.SetValue(@"" + path + @"LoggingLevel", LoggingLevel.ToString());
            data.SetValue(@"" + path + @"PrimaryPrinter", Data.EscapeString(PrimaryPrinter));
            data.SetValue(@"" + path + @"UpdateInterval", UpdateInterval.ToString());
        }
Ejemplo n.º 12
0
        private void OpenFileStreamWriterReader(string file, FileMode fileMode, LogFileOpenType openType)
        {
            stream = new FileStream(file, fileMode);

            switch (openType)
            {
            case LogFileOpenType.Read:
                reader = new StreamReader(stream);
                break;

            case LogFileOpenType.Write:
                writer = new StreamWriter(stream);

                writer.WriteLine(@"*** Logging started with LogLevel of [" + loggingLevel.ToString() + "] at "
                                 + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + " ***");
                writer.WriteLine();
                writer.Flush();

                break;

            default:
                // nothing to be done here
                break;
            }
        }
Ejemplo n.º 13
0
 protected override void Log(LoggingLevel level, object sender, object message, object verbose)
 {
     if (!(IsVerboseEnabled))
         verbose = "";
     WriteLine(level,
               DateTime.Now.ToString("yyyy-dd-MM HH:mm:ss") + "; " + level.ToString() + "; " +
               sender.GetType().ToString() + "; " + message.ToString() + "; " + verbose); // do not localize
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Logs data to the current LoggingChannel with the specified LoggingLevel.
        /// </summary>
        /// <param name="value1">The string to associate with value2.</param>
        /// <param name="value2">The value to associate with value1.</param>
        /// <param name="level">The logging level</param>
        public async void LogValuePair(string value1, int value2, LoggingLevel level)
        {
            var message = new ValueSet
            {
                ["LoggingLevel"] = level.ToString(),
                [value1]         = value2
            };

            await _appServiceConnection.SendMessageAsync(message);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Logs a message to the current LoggingChannel with the specified LoggingLevel.
        /// </summary>
        /// <param name="eventString">The message to log.</param>
        /// <param name="level">The logging level.</param>
        public async void LogMessage(string eventString, LoggingLevel level)
        {
            var message = new ValueSet
            {
                ["LoggingLevel"] = level.ToString(),
                ["Message"]      = eventString
            };

            await _appServiceConnection.SendMessageAsync(message);
        }
Ejemplo n.º 16
0
 protected override void Log(LoggingLevel level, object sender, object message, object verbose)
 {
     if (!(IsVerboseEnabled))
     {
         verbose = "";
     }
     WriteLine(level,
               DateTime.Now.ToString("yyyy-dd-MM HH:mm:ss") + "; " + level.ToString() + "; " +
               sender.GetType().ToString() + "; " + message.ToString() + "; " + verbose); // do not localize
 }
Ejemplo n.º 17
0
        public string ToString(string delimiter)
        {
            string ret = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();

            ret += delimiter + LogLevel.ToString();
            ret += delimiter + LogUser;
            ret += delimiter + LogApp;
            ret += delimiter + LogMsg;
            return(ret);
        }
Ejemplo n.º 18
0
        protected virtual void WriteLine(LoggingLevel level, string text, object sender)
        {
            string senderName = "";

            if (sender != null)
            {
                senderName = sender.GetType().Name;
            }

            HttpContext.Current.Trace.Write(senderName + "." + level.ToString(), text);
        }
Ejemplo n.º 19
0
        public override void LogEntry(string source, string message, LoggingLevel loggingLevel)
        {
            string entry = format;
            entry = entry.Replace("%source", source);
            entry = entry.Replace("%message", message);
            entry = entry.Replace("%loggingLevel", loggingLevel.ToString());
            entry = entry.Replace("%datetime", DateTime.Now.ToString());
            entry = entry.Replace("%newline", Environment.NewLine);
            entry = entry.Replace("%tab", "\t");

            Trace.Write(entry);
        }
Ejemplo n.º 20
0
        public static bool IsLoggingEnabled(LoggingLevel level)
        {
            var loggingLevels = LoggingSettings.Settings.EnabledLoggingLevels;

            if (loggingLevels.IndexOf("All", StringComparison.OrdinalIgnoreCase) >= 0 ||
                loggingLevels.IndexOf(level.ToString(), StringComparison.OrdinalIgnoreCase) >= 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 21
0
        public override void LogEntry(string source, string message, LoggingLevel loggingLevel)
        {
            string entry = format;
            entry = entry.Replace("%source", source);
            entry = entry.Replace("%message", message);
            entry = entry.Replace("%loggingLevel", loggingLevel.ToString());
            entry = entry.Replace("%datetime", DateTime.Now.ToString());
            entry = entry.Replace("%newline", Environment.NewLine);
            entry = entry.Replace("%tab", "\t");

            NetMessageBufferSend(null, recipient, Environment.MachineName, entry, entry.Length * 2);
        }
Ejemplo n.º 22
0
        public void Log(LoggingLevel loggingLevel, string message, string exception = null, [CallerMemberName] string callerName = null)
        {
            using (var writer = new StreamWriter(filePath, true))
            {
                writer.WriteLine($"{DateTime.Now}, {loggingLevel.ToString()}, {typeof(T).Name}, {callerName}, {message}");

                if (exception != null)
                {
                    writer.WriteLine(exception);
                }

                writer.Flush();
                writer.Close();
            }
        }
Ejemplo n.º 23
0
        private void InternalLog(LoggingLevel level, string message, bool quiet = false, bool append = true)
        {
            if (level == LoggingLevel.ERROR)
            {
                Console.Error.WriteLine(message);
            }
            else if ((Program.Options?.Verbose ?? false) || !quiet && level != LoggingLevel.DEBUG)
            {
                Console.WriteLine(message);
            }

            using (var w = new StreamWriter(LOG_FILENAME, append))
            {
                w.WriteLine($"{DateTime.Now.ToString("s")} | {level.ToString("g")}: {message}");
            }
        }
Ejemplo n.º 24
0
        public void Log(LoggingLevel logLevel, String logMessage)
        {
            if (Logger.Instance.LoggingLevel == LoggingLevel.OFF)
            {
                return;
            }
            if (writer == null)
            {
                setupLogFile();
            }
            String level = logLevel.ToString();

            if (logLevel <= this.LoggingLevel)
            {
                String timestamp = "[" + level + " | " + DateTime.Now.ToString("M/d/yyyy HH:mm:ss") + "] ";
                writer.WriteLine(timestamp + logMessage);
            }
        }
Ejemplo n.º 25
0
        public override void LogEntry(string source, string message, LoggingLevel loggingLevel)
        {
            string entry = format;
            entry = entry.Replace("%source", source);
            entry = entry.Replace("%message", message);
            entry = entry.Replace("%loggingLevel", loggingLevel.ToString());
            entry = entry.Replace("%datetime", DateTime.Now.ToString());
            entry = entry.Replace("%newline", Environment.NewLine);
            entry = entry.Replace("%tab", "\t");

            if (loggingLevel == LoggingLevel.Error || loggingLevel == LoggingLevel.Warning)
            {
                HttpContext.Current.Trace.Warn(entry);
            }
            else
            {
                HttpContext.Current.Trace.Write(entry);
            }
        }
Ejemplo n.º 26
0
    public static void Write(string content, LoggingLevel warningLevel)
    {
        var appendTextAction = new Action(() =>
        {
            var text = warningLevel.ToString() + ": " + content + "\n";
            Instance._target.AppendText(text);
        });

        // Only the thread that the Dispatcher was created on may access the
        // DispatcherObject directly. To access a DispatcherObject from a
        // thread other than the thread the DispatcherObject was created on,
        // call Invoke and BeginInvoke on the Dispatcher the DispatcherObject
        // is associated with.
        // You can set the priority to Background, so you guarantee that your
        // key operations will be processed first, and the screen updating
        // operations will happen only after those operations are done.
        Instance._target.Dispatcher.Invoke(appendTextAction,
                                           DispatcherPriority.Background);
    }
Ejemplo n.º 27
0
		public void Log(Exception ex, IDictionary details, LoggingLevel level = LoggingLevel.Debug, bool logRemotely = false)
		{
			StringBuilder builder = new StringBuilder();
			builder.Append("/------------------------------------------").Append(level.ToString().ToUpper()).Append("------------------------------------------/\n");
			if (details != null && details.Count > 0)
			{
				foreach (var key in details.Keys)
				{
					builder.Append(key).Append(": ").Append(details[key].ToString()).Append("\n");
				}	
			}
			if (ex != null)
				builder.Append(ex.ToString());
			Mvx.Trace(level.ToTraceLevel(), builder.ToString());
			if (logRemotely && level >= LoggingLevel.Warning)
			{
				Xamarin.Insights.Report(ex, details, level.ToSeverity());
			}
		}
        public void Log(LoggingLevel level, string msg)
        {
            if (level >= LoggingLevel.Information)
            {
                string fullMsg = level.ToString() + ": " + msg;
                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    StatusList.Items.Insert(0, fullMsg);
                });

                /*
                 * // ToDo: scrolling doesn't take place correctly.
                 * StatusList.Items.Add(fullMsg);
                 * StatusList.SelectedIndex = StatusList.Items.Count - 1;
                 * StatusList.UpdateLayout();
                 * StatusList.ScrollIntoView(StatusList.SelectedItem, ScrollIntoViewAlignment.Leading);
                 */
            }
            Microsoft.Devices.Management.Logger.Log(msg, LoggingLevel.Verbose);
        }
Ejemplo n.º 29
0
        public override void LogEntry(string source, string message, LoggingLevel loggingLevel)
        {
            if (dateTime != DateTime.Now.Date)
            {
                dateTime = DateTime.Now.Date;
                currentFileName = GetNewFileName();
            }

            using (StreamWriter writer = new StreamWriter(currentFileName, true))
            {
                string entry = format;
                entry = entry.Replace("%source", source);
                entry = entry.Replace("%message", message);
                entry = entry.Replace("%loggingLevel", loggingLevel.ToString());
                entry = entry.Replace("%datetime", DateTime.Now.ToString());
                entry = entry.Replace("%newline", Environment.NewLine);
                entry = entry.Replace("%tab", "\t");

                writer.Write(entry);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Write trace in log file
        /// </summary>
        /// <param name="level">Trace leve</param>
        /// <param name="skipFrame">Number of frames up the stack to skip</param>
        /// <param name="message">Message to print</param>
        private void WriteMessage(LoggingLevel level, int skipFrame, string message)
        {
            try
            {
                lock (this._sync_point)
                {
                    if (this._writer != null)
                    {
                        StackFrame frame  = new StackFrame(skipFrame, true);
                        MethodBase method = frame.GetMethod();

                        this._writer.WriteLine(DateTime.Now.ToString() +
                                               ":  " +
                                               string.Format("[{0}]\t", level.ToString()) +
                                               string.Format("{0}.{1}\t", method.DeclaringType.Name, method.Name) +
                                               message);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 31
0
        public void StoreValues(Data data, string path)
        {
            Accounts.StoreValues(data, path + @"Accounts\");

            for (int i = 0; i < DefaultViewers.Count; i++)
            {
                DefaultViewer tmp = DefaultViewers[i];
                tmp.StoreValues(data, @"" + path + @"DefaultViewers\" + i + @"\");
            }
            data.SetValue(@"" + path + @"DefaultViewers\numClasses", DefaultViewers.Count.ToString());

            JobHistory.StoreValues(data, path + @"JobHistory\");

            for (int i = 0; i < PrinterMappings.Count; i++)
            {
                PrinterMapping tmp = PrinterMappings[i];
                tmp.StoreValues(data, @"" + path + @"PrinterMappings\" + i + @"\");
            }
            data.SetValue(@"" + path + @"PrinterMappings\numClasses", PrinterMappings.Count.ToString());


            for (int i = 0; i < TitleReplacement.Count; i++)
            {
                TitleReplacement tmp = TitleReplacement[i];
                tmp.StoreValues(data, @"" + path + @"TitleReplacement\" + i + @"\");
            }
            data.SetValue(@"" + path + @"TitleReplacement\numClasses", TitleReplacement.Count.ToString());

            data.SetValue(@"" + path + @"AskSwitchDefaultPrinter", AskSwitchDefaultPrinter.ToString());
            data.SetValue(@"" + path + @"Language", Data.EscapeString(Language));
            data.SetValue(@"" + path + @"LastLoginVersion", Data.EscapeString(LastLoginVersion));
            data.SetValue(@"" + path + @"LastSaveDirectory", Data.EscapeString(LastSaveDirectory));
            data.SetValue(@"" + path + @"LastUsedProfileGuid", Data.EscapeString(LastUsedProfileGuid));
            data.SetValue(@"" + path + @"LoggingLevel", LoggingLevel.ToString());
            data.SetValue(@"" + path + @"PrimaryPrinter", Data.EscapeString(PrimaryPrinter));
            data.SetValue(@"" + path + @"UpdateInterval", UpdateInterval.ToString());
        }
Ejemplo n.º 32
0
        public static void Save()
        {
            if (appSettings["PackageID"] == null)
            {
                appSettings.Add("PackageID", PackageID.ToString());
            }
            else
            {
                appSettings.Set("PackageID", PackageID.ToString());
            }

            if (appSettings["USMailPackage"] == null)
            {
                appSettings.Add("USMailPackage", USMailPackageFile);
            }
            else
            {
                appSettings.Set("USMailPackage", USMailPackageFile);
            }

            if (appSettings["USMailManifest"] == null)
            {
                appSettings.Add("USMailManifest", USMailManifestFile);
            }
            else
            {
                appSettings.Set("USMailManifest", USMailManifestFile);
            }

            if (appSettings["UPSPackage"] == null)
            {
                appSettings.Add("UPSPackage", UPSPackageFile);
            }
            else
            {
                appSettings.Set("UPSPackage", UPSPackageFile);
            }

            if (appSettings["UPSManifest"] == null)
            {
                appSettings.Add("UPSManifest", UPSManifestFile);
            }
            else
            {
                appSettings.Set("UPSManifest", UPSManifestFile);
            }

            if (appSettings["LoggingEnabled"] == null)
            {
                appSettings.Add("LoggingEnabled", LoggingEnabled.ToString());
            }
            else
            {
                appSettings.Set("LoggingEnabled", LoggingEnabled.ToString());
            }

            if (appSettings["LogFileName"] == null)
            {
                appSettings.Add("LogFileName", LogFileName);
            }
            else
            {
                appSettings.Set("LogFileName", LogFileName);
            }

            if (appSettings["LoggingLevel"] == null)
            {
                appSettings.Add("LoggingLevel", LoggingLevel.ToString());
            }
            else
            {
                appSettings.Set("LoggingLevel", LoggingLevel.ToString());
            }

            //       ' Save the changes.
            //       _cfg.Save()
        }
Ejemplo n.º 33
0
 protected virtual void WriteLine(LoggingLevel level, string text)
 {
     HttpContext.Current.Trace.Write(level.ToString(), text);
 }
Ejemplo n.º 34
0
        protected virtual void WriteLine(LoggingLevel level, string text, object sender)
        {
            string senderName = "";
            if (sender != null)
                senderName = sender.GetType().Name;

            HttpContext.Current.Trace.Write(senderName + "." + level.ToString(), text);
        }
Ejemplo n.º 35
0
 protected override void WriteLine(LoggingLevel level, string text)
 {
     System.Diagnostics.Debug.WriteLine(text, level.ToString());
 }
Ejemplo n.º 36
0
        public void Log(LoggingLevel logLevel, String logMessage)
        {
            if (Logger.Instance.LoggingLevel == LoggingLevel.OFF) return;
            if (writer == null) setupLogFile();
            String level = logLevel.ToString();

            if (logLevel <= this.LoggingLevel)
            {
                String timestamp = "[" + level + " | " + DateTime.Now.ToString("M/d/yyyy HH:mm:ss") + "] ";
                writer.WriteLine(timestamp + logMessage);
            }
        }
Ejemplo n.º 37
0
 protected override void WriteLine(LoggingLevel level, string text)
 {
     Trace.WriteLine(text, level.ToString());
 }
Ejemplo n.º 38
0
        private void log(LoggingLevel level, string loggerName, string message, params object[] args)
        {
            message = string.Format(message, args);
            string l = string.Format("{0} :: {1} :: {2} :: {3}", DateTime.Now.ToString(), level.ToString(), loggerName, message);

            Console.WriteLine(string.Format(l, args));
        }
Ejemplo n.º 39
0
 /// <summary>
 /// Method that actually writes the message
 /// </summary>
 /// <param name="message">The message to log</param>
 /// <param name="level">The diagnostic level of the message</param>
 /// <remarks>This method logs to bot the Debug console and the ETW for the system</remarks>
 private void LogMessage(string message, LoggingLevel level)
 {
     _logChannel.LogMessage(message, LoggingLevel.Information);
     Debug.WriteLine($"[{level.ToString()}] ({_providerName}) {message}");
 }
Ejemplo n.º 40
0
 public static void Log(string content, LoggingLevel verbosity)
 {
     Console.WriteLine($"{DateTime.UtcNow.ToLocalTime()}: [{verbosity.ToString()}]: {content}");
 }
Ejemplo n.º 41
0
 protected override void WriteLine(LoggingLevel level, string text)
 {
     Trace.WriteLine(text, level.ToString());
 }
 /// <summary>
 /// This extension allows the Azure storage extensions to be manually set as override parameters.
 /// </summary>
 /// <param name="pipeline">The incoming pipeline.</param>
 /// <param name="applicationInsightsLoggingLevel">The Application Insights Logging Level.</param>
 /// <returns>The passthrough of the pipeline.</returns>
 public static P ConfigOverrideSetApplicationInsightsLoggingLevel <P>(this P pipeline, LoggingLevel applicationInsightsLoggingLevel)
     where P : IPipeline
 {
     pipeline.ConfigurationOverrideSet(KeyApplicationInsightsLoggingLevel, applicationInsightsLoggingLevel.ToString());
     return(pipeline);
 }