Beispiel #1
0
        /// <summary>
        /// Log the message to the the correct path
        /// </summary>
        /// <param name="message"></param>
        /// <param name="level"></param>
        /// <param name="reportModification"></param>
        private void Log(string message, LogLevel level, bool reportModification)
        {
            lock (this.guardMutex)
            {
                //Don't overwhelm the logging system
                if (debugSettings.VerboseLogging)
                {
                    Analytics.LogPiiInfo("LogMessage-" + level.ToString(), message);
                }

                // In test mode, write the logs only to std out.
                if (testMode)
                {
                    Console.WriteLine(string.Format("{0} : {1}", DateTime.UtcNow.ToString("u"), message));
                    return;
                }

                switch (level)
                {
                //write to the console
                case LogLevel.Console:
                    if (ConsoleWriter != null)
                    {
                        try
                        {
                            ConsoleWriter.AppendLine(string.Format("{0}", message));
                            FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.UtcNow.ToString("u"), message));
                            FileWriter.Flush();
                            RaisePropertyChanged("ConsoleWriter");
                        }
                        catch
                        {
                            // likely caught if the writer is closed
                        }
                    }
                    break;

                //write to the file
                case LogLevel.File:
                    if (FileWriter != null)
                    {
                        try
                        {
                            FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.UtcNow.ToString("u"), message));
                            FileWriter.Flush();
                        }
                        catch
                        {
                            // likely caught if the writer is closed
                        }
                    }
                    break;
                }

                if (reportModification)
                {
                    RaisePropertyChanged("LogText");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Log the message to the the correct path
        /// </summary>
        /// <param name="message"></param>
        private void Log(string message, LogLevel level, bool reportModification)
        {
            lock (this.guardMutex)
            {
                //Don't overwhelm the logging system
                if (dynSettings.Controller != null && !dynSettings.Controller.DebugSettings.VerboseLogging)
                {
                    InstrumentationLogger.LogInfo("LogMessage-" + level.ToString(), message);
                }

                switch (level)
                {
                //write to the console
                case LogLevel.Console:
                    if (ConsoleWriter != null)
                    {
                        try
                        {
                            ConsoleWriter.AppendLine(string.Format("{0}", message));
                            FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message));
                            FileWriter.Flush();
                            RaisePropertyChanged("ConsoleWriter");
                        }
                        catch
                        {
                            // likely caught if the writer is closed
                        }
                    }
                    break;

                //write to the file
                case LogLevel.File:
                    if (FileWriter != null)
                    {
                        try
                        {
                            FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message));
                            FileWriter.Flush();
                        }
                        catch
                        {
                            // likely caught if the writer is closed
                        }
                    }
                    break;
                }

                if (reportModification)
                {
                    RaisePropertyChanged("LogText");
                }
            }
        }
        /// <summary>
        /// Log the message to the the correct path
        /// </summary>
        /// <param name="message"></param>
        /// <param name="level"></param>
        /// <param name="reportModification"></param>
        private void Log(string message, LogLevel level, bool reportModification)
        {
            lock (this.guardMutex)
            {
                switch (level)
                {
                //write to the console
                case LogLevel.Console:
                    if (ConsoleWriter != null)
                    {
                        try
                        {
                            ConsoleWriter.AppendLine(string.Format("{0}", message));
                            FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now.ToString("u"), message));
                            FileWriter.Flush();
                            RaisePropertyChanged("ConsoleWriter");
                        }
                        catch
                        {
                            // likely caught if the writer is closed
                        }
                    }
                    break;

                //write to the file
                case LogLevel.File:
                    if (FileWriter != null)
                    {
                        try
                        {
                            FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now.ToString("u"), message));
                            FileWriter.Flush();
                        }
                        catch
                        {
                            // likely caught if the writer is closed
                        }
                    }
                    break;
                }

                if (reportModification)
                {
                    RaisePropertyChanged("LogText");
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Log the message to the the correct path
        /// </summary>
        /// <param name="message"></param>
        private void Log(string message, LogLevel level, bool reportModification)
        {
            InstrumentationLogger.LogInfo("LogMessage-" + level.ToString(), message);

            switch (level)
            {
            //write to the console
            case LogLevel.Console:
                if (ConsoleWriter != null)
                {
                    try
                    {
                        ConsoleWriter.AppendLine(string.Format("{0}", message));
                        FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message));
                        FileWriter.Flush();
                        RaisePropertyChanged("ConsoleWriter");
                    }
                    catch
                    {
                        // likely caught if the writer is closed
                    }
                }
                break;

            //write to the file
            case LogLevel.File:
                if (FileWriter != null)
                {
                    try
                    {
                        FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message));
                        FileWriter.Flush();
                    }
                    catch
                    {
                        // likely caught if the writer is closed
                    }
                }
                break;
            }

            if (reportModification)
            {
                RaisePropertyChanged("LogText");
            }
        }
Beispiel #5
0
        /// <summary>
        /// Log the message to the the correct path
        /// </summary>
        /// <param name="message"></param>
        public void Log(string message, LogLevel level)
        {
            switch (level)
            {
            //write to the console
            case LogLevel.Console:
                if (ConsoleWriter != null)
                {
                    try
                    {
                        ConsoleWriter.AppendLine(string.Format("{0}", message));
                        FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message));
                        FileWriter.Flush();
                        RaisePropertyChanged("ConsoleWriter");
                    }
                    catch
                    {
                        // likely caught if the writer is closed
                    }
                }
                break;

            //write to the file
            case LogLevel.File:
                if (FileWriter != null)
                {
                    try
                    {
                        FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message));
                        FileWriter.Flush();
                    }
                    catch
                    {
                        // likely caught if the writer is closed
                    }
                }
                break;
            }

            RaisePropertyChanged("LogText");
        }