Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set verbosity in Fable.Cli #3744

Merged
merged 3 commits into from Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -221,4 +221,6 @@ tests/**/*.actual

# Analyzers
*.sarif

# Temp proj file
*.fable-temp.csproj
2 changes: 1 addition & 1 deletion src/Fable.Cli/Entry.fs
Expand Up @@ -546,7 +546,7 @@ let main argv =
|> ignore
)

Log.setLogger (factory.CreateLogger(""))
Log.setLogger verbosity (factory.CreateLogger(""))
factory.Dispose()

logPrelude commands language
Expand Down
9 changes: 7 additions & 2 deletions src/Fable.Compiler/Util.fs
Expand Up @@ -85,9 +85,14 @@ module Log =
open Microsoft.Extensions.Logging.Abstractions

let mutable logger: ILogger = NullLogger.Instance
let setLogger newLogger = logger <- newLogger
let newLine = Environment.NewLine
let mutable private verbosity = Fable.Verbosity.Normal

let setLogger v newLogger =
verbosity <- v
logger <- newLogger

let newLine = Environment.NewLine

let isVerbose () = verbosity = Fable.Verbosity.Verbose
let always (msg: string) = logger.LogInformation msg

Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Compiler/Util.fsi
Expand Up @@ -41,7 +41,7 @@ module Log =
open Microsoft.Extensions.Logging

/// To be called only at the beginning of the app
val setLogger: ILogger -> unit
val setLogger: Fable.Verbosity -> ILogger -> unit
val newLine: string
val always: msg: string -> unit
val verbose: msg: Lazy<string> -> unit
Expand Down