Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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