Пример #1
0
        /// <summary>
        /// Initialises file logging.
        /// </summary>
        /// <returns>True if initialization actually happened.</returns>
        private static bool initFileLogging()
        {
            bool res = false;

            LogFileName = "log.txt";

            // Write some useful info at the top of the log file
            String preamble = String.Format("# Naiad log {0}{1}", DateTime.Now, CR);

            preamble += String.Format("# (timestamps are Windows file times){0}", CR);
            preamble += String.Format("# process_id, timestamp, elapsed_ms, mngd_thread_id, message{0}", CR);

            lock (logLock)
            {
                if (!Inited)
                {
                    buf = new CircularLogBuffer <string>(4, "");
                    buf.OverwriteIfFull = false; // don't lose any entries

                    LogFileStream = new FileStream(LogFileName, FileMode.Create);
                    LogWriter     = new StreamWriter(LogFileStream);
                    LogWriter.Write(preamble);
                    LogWriter.Flush();

                    Inited = true;
                    res    = true;
                }
            }
            return(res);
        }
Пример #2
0
        private static bool initInMemoryLogging()
        {
            bool res = false;

            lock (logLock)
            {
                if (!Inited)
                {
                    buf = new CircularLogBuffer <string>(64, "");
                    buf.OverwriteIfFull = true;
                    Inited = true;
                    res    = true;
                }
            }
            return(res);
        }