コード例 #1
0
 public void TestFlush()
 {
     using (var target = new TextWriterTraceListener(_stream))
     {
         target.Write(TestMessage);
         target.Flush();
     }
 }
コード例 #2
0
        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();
        }
コード例 #3
0
 public void TestFlush()
 {
     using (var target = new TextWriterTraceListener(_stream))
     {
         target.Write(TestMessage);
         target.Flush();
     }
 }
コード例 #4
0
ファイル: Logger.cs プロジェクト: Warwick858/Algorithms
        public static void Write(string msg)
        {
            TextWriterTraceListener output = new TextWriterTraceListener(_logPath, "log");

            output.Write(msg);
            output.Flush();
            output.Dispose();
        }
コード例 #5
0
        public void TestWriteAfterDisposeShouldNotThrow()
        {
            var target = new TextWriterTraceListener(_stream);
            target.Dispose();

            target.WriteLine(TestMessage);
            target.Write(TestMessage);
            target.Flush();
        }
コード例 #6
0
        public void TestWrite()
        {
            using (var target = new TextWriterTraceListener(_stream))
            {
                target.Write(TestMessage);
            }

            Assert.Contains(TestMessage, File.ReadAllText(_fileName));
        }
コード例 #7
0
        public void TestWrite()
        {
            using (var target = new TextWriterTraceListener(_stream))
            {
                target.Write(TestMessage);
            }

            Assert.Contains(TestMessage, File.ReadAllText(_fileName));
        }
コード例 #8
0
        public void TestWriteAfterDisposeShouldNotThrow()
        {
            var target = new TextWriterTraceListener(_stream);

            target.Dispose();

            target.WriteLine(TestMessage);
            target.Write(TestMessage);
            target.Flush();
        }
コード例 #9
0
ファイル: source.cs プロジェクト: zeromus/dotnet-api-docs
    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();
    }
コード例 #10
0
 /// <summary>
 /// Writes the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <remarks></remarks>
 public override void Write(string message)
 {
     listener.Write(message, CreateMessage());
 }
コード例 #11
0
 public override void Write(string Text)
 {
     Output.Write(Text);
     //Form.TraceTextBox.Text += Text;
     //Form.TraceTextBox.ScrollToCaret();
 }
コード例 #12
0
 public void TestWrite()
 {
     Assert.IsTrue(!(listener == null), "Null Listener");
     Assert.IsTrue(!(listener.Writer == null), "Null Writer");
     listener.Write("Test Message\n");
 }
コード例 #13
0
 public override void Write(string message)
 {
     textTraceListener.Write(message);
 }
コード例 #14
0
 public static void Trace()
 {
     m_traceListener = new TextWriterTraceListener();
     m_traceListener.Write("");
     m_traceListener.Writer.ToString();
 }
コード例 #15
0
ファイル: App.xaml.cs プロジェクト: unknowphoton/power8
        /// <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;
        }