Ejemplo n.º 1
0
        /// <summary>
        /// Starts logging to the specified file
        /// </summary>
        /// <param name="logFileName">The path to the log file</param>
        /// <param name="loggedLevels">The levels that will be logged in the file</param>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  08/09/11 RCG 2.52.00        Created
        //  05/28/14 jrf 4.00.15 WR517731 Removing use of FileInfo object. It was the only thing that could have been
        //                               accessing the log file and causing the System.IO.IOException during the call
        //                               to the FileStream's constructor.
        public void StartLogging(string logFileName, EZSPLogLevels loggedLevels)
        {
            m_LoggedLevels = loggedLevels;

            if (Directory.Exists(Path.GetDirectoryName(logFileName)) == false && !string.IsNullOrEmpty(Path.GetDirectoryName(logFileName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(logFileName));
            }

            m_LogFileStream           = new FileStream(logFileName, FileMode.Create, FileAccess.Write);
            m_LogFileWriter           = new StreamWriter(m_LogFileStream);
            m_LogFileWriter.AutoFlush = true;

            m_LoggingEnabled = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes the specified line to the log
        /// </summary>
        /// <param name="logLevel">The log level of the line to write</param>
        /// <param name="logText">The text to write to the log</param>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  08/09/11 RCG 2.52.00        Created

        public void WriteLine(EZSPLogLevels logLevel, string logText)
        {
            string Output = DateTime.Now.ToString(DATE_FORMAT_STRING, CultureInfo.InvariantCulture) + " " + logText;

            if (m_LoggingEnabled && ShouldLog(logLevel))
            {
                try
                {
                    lock (m_LogFileWriter)
                    {
                        m_LogFileWriter.WriteLine(Output);
                    }
                }
                catch
                {
                    // We don't care if this fails.
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines whether or not the item should be logged
        /// </summary>
        /// <param name="logLevel">The level to check</param>
        /// <returns>True if the level is being logged. False otherwise</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ -------------------------------------------
        //  08/09/11 RCG 2.52.00        Created

        private bool ShouldLog(EZSPLogLevels logLevel)
        {
            return((logLevel & m_LoggedLevels) == logLevel);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Starts EZSP level logging
        /// </summary>
        /// <param name="filePath">The path to the log file</param>
        /// <param name="logLevel">The logging level</param>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 03/13/13 RCG 2.70.72 327410 Created

        public void StartLogging(string filePath, EZSPLogLevels logLevel)
        {
            C177App.StartLogging(filePath, logLevel);
        }