public void TestFlush() { using (var target = new TextWriterTraceListener(_stream)) { target.Write(TestMessage); target.Flush(); } }
public void enterRecord(string record) { TextWriterTraceListener myListener = new TextWriterTraceListener(AppDomain.CurrentDomain.BaseDirectory + "LOGS\\" + DateTime.Now.ToString("yyyyMMdd") + ".log", "MyListener"); myListener.Write(DateTime.Now + " -> "); myListener.WriteLine(record); myListener.Flush(); }
public static void Write(string msg) { TextWriterTraceListener output = new TextWriterTraceListener(_logPath, "log"); output.Write(msg); output.Flush(); output.Dispose(); }
public void TestWriteAfterDisposeShouldNotThrow() { var target = new TextWriterTraceListener(_stream); target.Dispose(); target.WriteLine(TestMessage); target.Write(TestMessage); target.Flush(); }
public void TestWrite() { using (var target = new TextWriterTraceListener(_stream)) { target.Write(TestMessage); } Assert.Contains(TestMessage, File.ReadAllText(_fileName)); }
void Main(string[] args) { /* Create a text writer that writes to the console screen and add * it to the trace listeners */ TextWriterTraceListener myWriter = new TextWriterTraceListener(); myWriter.Writer = System.Console.Out; Trace.Listeners.Add(myWriter); // Write the output to the console screen. myWriter.Write("Write to console screen. "); myWriter.WriteLine("Again, write to the Console screen."); // Flush and close the output. myWriter.Flush(); myWriter.Close(); }
/// <summary> /// Writes the specified message. /// </summary> /// <param name="message">The message.</param> /// <remarks></remarks> public override void Write(string message) { listener.Write(message, CreateMessage()); }
public override void Write(string Text) { Output.Write(Text); //Form.TraceTextBox.Text += Text; //Form.TraceTextBox.ScrollToCaret(); }
public void TestWrite() { Assert.IsTrue(!(listener == null), "Null Listener"); Assert.IsTrue(!(listener.Writer == null), "Null Writer"); listener.Write("Test Message\n"); }
public override void Write(string message) { textTraceListener.Write(message); }
public static void Trace() { m_traceListener = new TextWriterTraceListener(); m_traceListener.Write(""); m_traceListener.Writer.ToString(); }
/// <summary> /// Application initializer. Performs compatibility check, /// starts diagnostics if required, works settings around, /// and initializes the process of generating of internal data structures. /// </summary> public App() { if (Util.OsIs.VistaExact) //If run on shit { MessageBox.Show( Power8.Properties.Resources.Err_VistaDetected, Power8.Properties.NoLoc.Stg_AppShortName, MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(2); //means: OS not found } //Global error mode setter - in 1st place to fix nasty startup error on Win10x86 API.SetErrorMode(API.ErrMode.FailCriticalErrors); //Power8s in our session but with different pid foreach (var p in Process.GetProcessesByName("Power8") .Where(p => p.SessionId == Proc.SessionId && p.Id != Proc.Id)) { p.Kill(); } Util.MainDisp = Dispatcher; //store main thread dispatcher. Widely used in Application. #if DEBUG //System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("ru"); //Error handling and detection var l = new TextWriterTraceListener(Environment.ExpandEnvironmentVariables(@"%temp%\p8log.txt")); l.Write("\r\n\r\nPower8 Log opened at " + DateTime.Now + "\r\n\r\n"); Debug.AutoFlush = true; Debug.Listeners.Add(l); #endif DispatcherUnhandledException += (sender, e) => Util.DispatchUnhandledException(e.Exception); AppDomain.CurrentDomain.UnhandledException += HandleUnhandled; ServicePointManager.SecurityProtocol |= (SecurityProtocolType)3840; //Support for TLS 1.1 and TLS 1.2 var dbRoot = Util.GetSettingsIndependentDbRoot(); try { var ids = Directory.GetFiles(dbRoot, "*" + ClientIDExtension); string clientId; if (ids.Length == 0) { clientId = Guid.NewGuid().ToString(); File.Create(dbRoot + "\\" + clientId + ClientIDExtension); } else { clientId = Path.GetFileNameWithoutExtension(ids[0]); } Analytics.Init(TrackID, clientId, Power8.Properties.NoLoc.Stg_AppShortName, Util.GetAppVersion().ToString()); } catch (Exception ex) { Log.Raw("Unable to read client ID to init analytics: " + ex); } //Move settings from previous ver var std = Power8.Properties.Settings.Default; if (!std.FirstRunDone) { try { std.Upgrade(); } catch (Exception ex) { Log.Raw("Unable to upgrade settings: " + ex); } std.Save();//FirstRunDone is updated later in Main Window code Analytics.PostEvent(Analytics.Category.Deploy, std.FirstRunDone ? "Update" : "Fresh", null, 1); BtnStck.Instanciated += (o, e) => Util.InstanciateClass(t: typeof(Donate)); } //Initialize standard folder icon ImageManager.GetImageContainerSync(new PowerItem { Argument = dbRoot, IsFolder = true }, API.Shgfi.SMALLICON); //Build tree Util.ForkPool(PowerItemTree.InitTree, "InitTree"); //react on DwmCompositionChanged event ComponentDispatcher.ThreadFilterMessage += WndProc; }