Skip to content

Commit

Permalink
Remove Log setup from fsx (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkbeforecoding authored Sep 28, 2020
1 parent 64e50b6 commit 420e4a4
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions src/FSharp.Formatting/FSharp.Formatting.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,3 @@
#r "FSharp.Formatting.CodeFormat.dll"
#r "FSharp.Formatting.ApiDocs.dll"

// Setup Logging for FSharp.Formatting and FSharp.Formatting.Internal
module Logging = FSharp.Formatting.Common.Log
type TraceOptions = System.Diagnostics.TraceOptions

// By default, we log to console only. Other modes are enabled by setting
// the `FSHARP_FORMATTING_LOG` environment variable.
let logToFile, logToConsole =
match System.Environment.GetEnvironmentVariable("FSHARP_FORMATTING_LOG") with
| "ALL" -> true, true
| "NONE" -> false, false
| "FILE_ONLY" -> true, false
| _ -> false, true

try
let allTraceOptions =
TraceOptions.Callstack ||| TraceOptions.DateTime ||| TraceOptions.LogicalOperationStack |||
TraceOptions.ProcessId ||| TraceOptions.ThreadId ||| TraceOptions.Timestamp
let noTraceOptions = TraceOptions.None
let svclogFile = "FSharp.Formatting.svclog"
System.Diagnostics.Trace.AutoFlush <- true

let setupListener listener =
[ FSharp.Formatting.Common.Log.source
FSharp.Formatting.Internal.Log.source ]
|> Seq.iter (fun source ->
source.Switch.Level <- System.Diagnostics.SourceLevels.All
Logging.AddListener listener source)

if logToConsole then
Logging.ConsoleListener()
|> Logging.SetupListener noTraceOptions System.Diagnostics.SourceLevels.Verbose
|> setupListener

// Test that everything works
Logging.infof "FSharp.Formatting Logging setup!"
FSharp.Formatting.Internal.Log.infof "FSharp.Formatting.Internal Logging setup!"
with e ->
printfn "FSharp.Formatting Logging setup failed: %A" e

0 comments on commit 420e4a4

Please sign in to comment.