@@ -31,6 +31,7 @@ open Config
3131open System.Diagnostics .Metrics
3232open System.Text
3333open Microsoft.VisualStudio .Threading
34+ open Microsoft.VisualStudio .FSharp .Editor .CancellableTasks
3435
3536module FSharpOutputPane =
3637
@@ -56,29 +57,17 @@ module FSharpOutputPane =
5657 let private log logType msg =
5758 task {
5859 System.Diagnostics.Trace.TraceInformation( msg)
59- let time = DateTime.Now.ToString( " hh:mm:ss tt" )
60-
6160 let! pane = pane.GetValueAsync()
6261
6362 do ! ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync()
6463
6564 match logType with
66- | LogType.Message ->
67- String.Format( " [{0}{1}] {2}{3}" , " " , time, msg, Environment.NewLine)
68- |> pane.OutputStringThreadSafe
69- |> ignore
70- | LogType.Info ->
71- String.Format( " [{0}{1}] {2}{3}" , " INFO " , time, msg, Environment.NewLine)
72- |> pane.OutputStringThreadSafe
73- |> ignore
74- | LogType.Warn ->
75- String.Format( " [{0}{1}] {2}{3}" , " WARN " , time, msg, Environment.NewLine)
76- |> pane.OutputStringThreadSafe
77- |> ignore
78- | LogType.Error ->
79- String.Format( " [{0}{1}] {2}{3}" , " ERROR " , time, msg, Environment.NewLine)
80- |> pane.OutputStringThreadSafe
81- |> ignore
65+ | LogType.Message -> $" {msg}"
66+ | LogType.Info -> $" [INFO] {msg}"
67+ | LogType.Warn -> $" [WARN] {msg}"
68+ | LogType.Error -> $" [ERROR] {msg}"
69+ |> pane.OutputStringThreadSafe
70+ |> ignore
8271 }
8372 |> ignore
8473
@@ -102,6 +91,7 @@ module FSharpOutputPane =
10291
10392module FSharpServiceTelemetry =
10493 open FSharp.Compiler .Caches
94+ open System.Threading .Tasks
10595
10696 let listen filter =
10797 let indent ( activity : Activity ) =
@@ -130,6 +120,15 @@ module FSharpServiceTelemetry =
130120
131121 ActivitySource.AddActivityListener( listener)
132122
123+ let periodicallyDisplayCacheStats =
124+ cancellableTask {
125+ use _ = CacheMetrics.ListenToAll()
126+
127+ while true do
128+ do ! Task.Delay( TimeSpan.FromSeconds 10.0 )
129+ FSharpOutputPane.logMsg ( CacheMetrics.StatsToString())
130+ }
131+
133132#if DEBUG
134133 open OpenTelemetry.Resources
135134 open OpenTelemetry.Trace
0 commit comments