コード例 #1
0
        /// <summary>
        /// On initializing.. adding/updating init time value
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="initTime"></param>
        public static void Initialize(string fileName, string initTime)
        {
            try
            {
                if (string.IsNullOrEmpty(fileName))
                {
                    Debug.Assert(false, "fileName is not defined");
                    fileName = Assembly.GetEntryAssembly().GetName().Name + ".log";
                }
                _xmlFilePath = Path.Combine(PathConstants.GetConfigPath(), fileName + ".xml");

                if (!File.Exists(_xmlFilePath))
                {
                    using (XmlWriter writer = XmlWriter.Create(_xmlFilePath))
                    {
                        writer.WriteStartElement("settings");
                        writer.WriteElementString("initTime", initTime);
                        writer.WriteEndElement();
                        writer.Flush();
                    }
                }
            }
            catch (Exception ex)
            {
                LogWriter.Error("Error while initializing settings file " + ex.Message);
            }
        }
コード例 #2
0
        public static void Initialize(string fileName, bool useQueue = false)
        {
            lock (_locker)
            {
                if (string.IsNullOrEmpty(fileName))
                {
                    Debug.Assert(false, "fileName is not defined");
                    fileName = Assembly.GetEntryAssembly().GetName().Name + ".log";
                }
                _logFilePath = Path.Combine(PathConstants.GetLogPath(), fileName + ".log");

                if (useQueue)
                {
                    _queue = new ProducerConsumerQueue <string>(OnMessageReceived, true, "LogWriter");
                }
                Info("========================= LogWriter initialized ==========================================================");
            }
        }