当前位置: 首页>>代码示例>>C#>>正文


C# SystemDiagnostics.Log方法代码示例

本文整理汇总了C#中SystemDiagnostics.Log方法的典型用法代码示例。如果您正苦于以下问题:C# SystemDiagnostics.Log方法的具体用法?C# SystemDiagnostics.Log怎么用?C# SystemDiagnostics.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SystemDiagnostics的用法示例。


在下文中一共展示了SystemDiagnostics.Log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateStorageDirectory

        private static void CreateStorageDirectory(IFileSystem fileSystem, string storageDirectory, SystemDiagnostics diagnostics)
        {
            if (fileSystem.Directory.Exists(storageDirectory))
            {
                diagnostics.Log(
                    LevelToLog.Info,
                    ExecutorConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.Log_Messages_RemovingStorageDirectory_WithDirectory,
                        storageDirectory));

                fileSystem.Directory.Delete(storageDirectory, true);
            }

            if (!fileSystem.Directory.Exists(storageDirectory))
            {
                diagnostics.Log(
                    LevelToLog.Debug,
                    ExecutorConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.Log_Messages_CreatingStorageDirectory_WithDirectory,
                        storageDirectory));

                fileSystem.Directory.CreateDirectory(storageDirectory);
            }
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:28,代码来源:Program.cs

示例2: WaitForResponse

        public static bool WaitForResponse(
            Func<bool> hasHadResponse,
            SystemDiagnostics diagnostics,
            string eventDescription,
            int maximumWaitTimeInMilliSeconds,
            int cycleTimeInMilliSeconds)
        {
            var maximumWaitTime = TimeSpan.FromMilliseconds(maximumWaitTimeInMilliSeconds);
            var killTime = DateTimeOffset.Now + maximumWaitTime;
            while (!hasHadResponse())
            {
                diagnostics.Log(
                    LevelToLog.Trace,
                    MachineConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "Waiting for event: {0}",
                        eventDescription));

                Thread.Sleep(cycleTimeInMilliSeconds);
                if (DateTimeOffset.Now > killTime)
                {
                    diagnostics.Log(
                    LevelToLog.Trace,
                    MachineConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "Event [{0}] did not occur within the designated time window of {1}",
                        eventDescription,
                        maximumWaitTime));

                    return false;
                }
            }

            return true;
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:37,代码来源:MachineHelpers.cs

示例3: OnStart

        /// <summary>
        /// When implemented in a derived class, executes when a Start command is sent
        /// to the service by the Service Control Manager (SCM) or when the operating
        /// system starts (for a service that starts automatically). Specifies actions
        /// to take when the service starts.
        /// </summary>
        public void OnStart()
        {
            lock (m_Lock)
            {
                if ((m_Uploader != null) || (m_Indexer != null) || (m_Container != null))
                {
                    OnStop();
                }

                m_Container = DependencyInjection.CreateContainer();
                m_Uploader = m_Container.Resolve<IUploadPackages>();
                m_Indexer = m_Container.Resolve<IIndexSymbols>();
                m_Diagnostics = m_Container.Resolve<SystemDiagnostics>();

                m_Diagnostics.Log(
                    LevelToLog.Info,
                    Resources.Log_Messages_ServiceEntryPoint_StartingService);

                m_Indexer.Start();
                m_Uploader.EnableUpload();
            }
        }
开发者ID:pvandervelde,项目名称:nAnicitus,代码行数:28,代码来源:ServiceEntryPoint.cs

示例4: RollbackExecutedStepsOnFailure

        private static void RollbackExecutedStepsOnFailure(
            List<Tuple<TestStep, IParticipateInCleanUp>> executedSteps,
            SystemDiagnostics diagnostics,
            ITestSectionBuilder sectionWriter)
        {
            try
            {
                for (int i = executedSteps.Count - 1; i > -1; i--)
                {
                    var pair = executedSteps[i];
                    diagnostics.Log(
                        LevelToLog.Info,
                        ExecutorConstants.LogPrefix,
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.Log_Messages_CleaningUpTestStep_WithStepAndTestStepType,
                            pair.Item1.Order,
                            pair.Item1.GetType()));

                    pair.Item2.CleanUp(pair.Item1);
                }
            }
            catch (Exception e)
            {
                diagnostics.Log(
                    LevelToLog.Error,
                    ExecutorConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.Log_Messages_FailedToCleanUp_WithError,
                        e));

                sectionWriter.AddErrorMessage(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.Reporting_TestExecution_CleanupFailed_WithException,
                        e));
            }
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:39,代码来源:Program.cs


注:本文中的SystemDiagnostics.Log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。