提交 a593db82 编写于 作者: C CyrusNajmabadi

Make the logging service async. That way we can move package update out of...

Make the logging service async.  That way we can move package update out of proc while still logginc to the VS log in a non-blocking fashion.
上级 36cbe2cb
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
......@@ -9,7 +10,7 @@ namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
/// </summary>
internal interface ILogService
{
void LogException(Exception e, string text);
void LogInfo(string text);
Task LogExceptionAsync(Exception e, string text);
Task LogInfoAsync(string text);
}
}
}
\ No newline at end of file
......@@ -2,7 +2,9 @@
using System;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Roslyn.Utilities;
using Microsoft.VisualStudio.Shell.Interop;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.LanguageServices.SymbolSearch
{
......@@ -17,18 +19,24 @@ public LogService(IVsActivityLog activityLog)
_activityLog = activityLog;
}
public void LogInfo(string text)
public Task LogInfoAsync(string text)
{
Log(text, __ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION);
return LogAsync(text, __ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION);
}
public void LogException(Exception e, string text)
public Task LogExceptionAsync(Exception e, string text)
{
Log(text + ". " + e.ToString(), __ACTIVITYLOG_ENTRYTYPE.ALE_ERROR);
return LogAsync(text + ". " + e.ToString(), __ACTIVITYLOG_ENTRYTYPE.ALE_ERROR);
}
private void Log(string text, __ACTIVITYLOG_ENTRYTYPE type)
private Task LogAsync(string text, __ACTIVITYLOG_ENTRYTYPE type)
{
Log(text, type);
return SpecializedTasks.EmptyTask;
}
private void Log(string text, __ACTIVITYLOG_ENTRYTYPE type)
{
if (!this.IsForeground())
{
this.InvokeBelowInputPriority(() => Log(text, type));
......
......@@ -13,6 +13,7 @@ Imports Microsoft.Internal.VisualStudio.Shell.Interop
Imports Microsoft.VisualStudio.LanguageServices.SymbolSearch
Imports Moq
Imports Roslyn.Test.Utilities
Imports Roslyn.Utilities
Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.SymbolSearch
Public Class SymbolSearchServiceTests
......@@ -817,11 +818,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.SymbolSearch
Private Sub New()
End Sub
Public Sub LogException(e As Exception, text As String) Implements ILogService.LogException
End Sub
Public Function LogExceptionAsync(e As Exception, text As String) As Task Implements ILogService.LogExceptionAsync
Return SpecializedTasks.EmptyTask
End Function
Public Sub LogInfo(text As String) Implements ILogService.LogInfo
End Sub
Public Function LogInfoAsync(text As String) As Task Implements ILogService.LogInfoAsync
Return SpecializedTasks.EmptyTask
End Function
End Class
End Class
End Namespace
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册