Skip to content

Commit

Permalink
Set verbosity in Fable.Cli
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Feb 8, 2024
1 parent bb09d11 commit cdf273c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Fable.Cli/Entry.fs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
18 changes: 18 additions & 0 deletions src/quicktest/QuickTest.fable-temp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<!--This is a temporary file used by Fable to restore dependencies.
If you see this file in your project, you can delete it safely-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RollForward>Major</RollForward>
<LangVersion>Preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="QuickTest.fs" />
<Content Include="quicktest.fs.js" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../Fable.Core/Fable.Core.fsproj" />
</ItemGroup>
</Project>

0 comments on commit cdf273c

Please sign in to comment.