Ejemplo n.º 1
0
 public void SetOptions(LogWriterOptions options)
 {
     if (this._options == options)
     {
         return;
     }
     this._options = options;
     foreach (var w in this._writers)
     {
         w.SetOptions(options);
     }
 }
Ejemplo n.º 2
0
        private LogWriterOptions GetLogWriterOptions(CTestAdapterOptionPage options)
        {
            if (null == options)
            {
                options = (CTestAdapterOptionPage)this.GetDialogPage(typeof(CTestAdapterOptionPage));
                options.LoadSettingsFromStorage();
            }
            var logOpts = new LogWriterOptions()
            {
                CurrentLogLevel = options.CurrentLogLevel,
                EnableLogFile   = options.EnableLogFile,
                LogFileName     = options.LogFileName,
                AppendToLogFile = options.AppendToLogFile
            };

            return(logOpts);
        }
Ejemplo n.º 3
0
 public void SetOptions(LogWriterOptions options)
 {
     if (this._opts == options)
     {
         return;
     }
     if (!options.EnableLogFile)
     {
         this.CloseLogFile();
     }
     else if (options.LogFileName != this._opts.LogFileName ||
              options.EnableLogFile != this._opts.EnableLogFile)
     {
         this.TryInitializeLogFile(options);
     }
     this._opts = options;
 }
Ejemplo n.º 4
0
        private void TryInitializeLogFile(LogWriterOptions newopts)
        {
            if (null != this._writer)
            {
                return;
            }
            if (!newopts.EnableLogFile)
            {
                return;
            }
            if (newopts.LogFileName.Length == 0)
            {
                return;
            }
            var info = new FileInfo(newopts.LogFileName);

            if (!Directory.Exists(info.DirectoryName))
            {
                return;
            }
            if (newopts.LogFileName == Constants.AdapterLogFileNameInvalid)
            {
                return;
            }
            this._writer = new StreamWriter(
                newopts.LogFileName,
                newopts.AppendToLogFile,
                Encoding.UTF8)
            {
                AutoFlush = true
            };
            if (null != this._writer)
            {
                this.Log(LogLevel.Info, "opened logfile: " + newopts.LogFileName);
                var name = Assembly.GetExecutingAssembly().GetName();
                this.Log(LogLevel.Info, "assembly: " + name.Name);
                this.Log(LogLevel.Info, "assembly version: " + name.Version.ToString());
                this.Log(LogLevel.Info, "--------------------------------------");
            }
        }
Ejemplo n.º 5
0
 public void SetOptions(LogWriterOptions options)
 {
     this._opts = options;
 }