コード例 #1
0
ファイル: Log.cs プロジェクト: FinnZan/DebugViewF
 public static void Log(string log, int levelShift = 0)
 {
     if (_logEnabled)
     {
         LoggerCore.Log(log, levelShift);
     }
 }
コード例 #2
0
ファイル: CommonTools_Log.cs プロジェクト: FinnZan/DebugViewF
        /// <summary>
        ///
        /// </summary>
        /// <param name="appName"></param>
        /// <param name="app">The "host" app</param>
        /// <param name="logDepth">
        ///     How many layaer up on the stack we should go so we can show the actual method we are interested in
        /// </param>
        /// <param name="writeFile"></param>
        public static string InitializeDebugger(string appName)
        {
            _appName = appName.Replace(" ", "_");

            PutLogger();

            LoggerCore.Start(_appName, 2);

            if (AttachTraceListener())
            {
                new Thread(
                    () =>
                {
                    while (_running)
                    {
                        ReadTrace();
                        Thread.Sleep(500);
                    }
                }).Start();
            }
            else
            {
                LoggerCore.Log("TRACE failed.");
            }

            _logEnabled = true;

            return(string.Empty);
        }
コード例 #3
0
ファイル: CommonTools_Log.cs プロジェクト: FinnZan/DebugViewF
        private static void PutLogger()
        {
            var name = $"{_appName} Log View";

            Process[] processlist = Process.GetProcesses();

            foreach (Process process in processlist)
            {
                if (!String.IsNullOrEmpty(process.MainWindowTitle) && process.MainWindowTitle == name)
                {
                    return;
                }
            }

            try
            {
                var codeBase = Assembly.GetExecutingAssembly().CodeBase;
                var uri      = new UriBuilder(codeBase);
                var dllPath  = Uri.UnescapeDataString(uri.Path);
                var path     = Path.Combine(Path.GetDirectoryName(dllPath), "LogReader.exe");

                File.WriteAllBytes(path, Resources.LogReader);

                var lps = new LaunchProcessFromService();
                lps.LaunchProcess(path, $" RunAsServer {_appName}");
            }
            catch (Exception ex)
            {
                if (ex.ToString().Contains("LogReader.exe' because it is being used by another process."))
                {
                    LoggerCore.Log("LogReader already running.");
                }
                else
                {
                    LoggerCore.HandleException(ex);
                }
            }
        }