未验证 提交 2ce1825f 编写于 作者: J Jakub Majocha 提交者: GitHub

VS: log activities to output pane in debug (#15028)

* dump activities to output pane
上级 1515f5ee
......@@ -71,19 +71,19 @@ type Logger [<ImportingConstructor>] ([<Import(typeof<SVsServiceProvider>)>] ser
match self.FSharpLoggingPane, msgType with
| None, _ -> ()
| Some pane, LogType.Message ->
String.Format("[F#][{0}{1}] {2}{3}", "", time, msg, Environment.NewLine)
String.Format("[{0}{1}] {2}{3}", "", time, msg, Environment.NewLine)
|> pane.OutputString
|> ignore
| Some pane, LogType.Info ->
String.Format("[F#][{0}{1}] {2}{3}", "INFO ", time, msg, Environment.NewLine)
String.Format("[{0}{1}] {2}{3}", "INFO ", time, msg, Environment.NewLine)
|> pane.OutputString
|> ignore
| Some pane, LogType.Warn ->
String.Format("[F#][{0}{1}] {2}{3}", "WARN ", time, msg, Environment.NewLine)
String.Format("[{0}{1}] {2}{3}", "WARN ", time, msg, Environment.NewLine)
|> pane.OutputString
|> ignore
| Some pane, LogType.Error ->
String.Format("[F#][{0}{1}] {2}{3}", "ERROR ", time, msg, Environment.NewLine)
String.Format("[{0}{1}] {2}{3}", "ERROR ", time, msg, Environment.NewLine)
|> pane.OutputString
|> ignore
......@@ -112,3 +112,34 @@ module Logging =
let logExceptionWithContext (ex: Exception, context) =
logErrorf "Context: %s\nException Message: %s\nStack Trace: %s" context ex.Message ex.StackTrace
module Activity =
let listen filter =
let indent (activity: Activity) =
let rec loop (activity: Activity) n =
if activity.Parent <> null then
loop (activity.Parent) (n + 1)
else
n
String.replicate (loop activity 0) " "
let collectTags (activity: Activity) =
[ for tag in activity.Tags -> $"{tag.Key}: %A{tag.Value}" ]
|> String.concat ", "
let listener =
new ActivityListener(
ShouldListenTo = (fun source -> source.Name = FSharp.Compiler.Diagnostics.ActivityNames.FscSourceName),
Sample =
(fun context ->
if context.Name.Contains(filter) then
ActivitySamplingResult.AllDataAndRecorded
else
ActivitySamplingResult.None),
ActivityStarted = (fun a -> logMsg $"{indent a}{a.OperationName} {collectTags a}")
)
ActivitySource.AddActivityListener(listener)
let listenToAll () = listen ""
......@@ -321,6 +321,11 @@ type internal FSharpPackage() as this =
let mutable solutionEventsOpt = None
#if DEBUG
let _logger = Logging.Activity.listenToAll ()
// Logging.Activity.listen "IncrementalBuild"
#endif
// FSI-LINKAGE-POINT: unsited init
do Microsoft.VisualStudio.FSharp.Interactive.Hooks.fsiConsoleWindowPackageCtorUnsited (this :> Package)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册