-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.fs
More file actions
42 lines (37 loc) · 1.36 KB
/
Utils.fs
File metadata and controls
42 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module Scripts.Utils
open Serilog
open Serilog.Events
open CliWrap
open Serilog.Filters
let setupLogging (verbose: bool) =
Log.Logger <-
LoggerConfiguration()
.Enrich.FromLogContext()
.Filter.ByExcluding(Matching.FromSource("MsBuild"))
.Filter.ByExcluding(Matching.FromSource("Ionide.ProjInfo.WorkspaceLoaderViaProjectGraph"))
.WriteTo
.Console(
outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] {SourceContext} {step:j}: {Message:lj}{NewLine}{Exception}"
)
.MinimumLevel
.Is(
if verbose then
LogEventLevel.Verbose
else
LogEventLevel.Information
)
.CreateLogger()
let repoDir = __SOURCE_DIRECTORY__
type Command with
member this.ExecuteAssertSuccess() =
let command =
this
.WithValidation(CommandResultValidation.ZeroExitCode)
.WithStandardErrorPipe(PipeTarget.ToFile "stderr.txt")
.WithStandardOutputPipe(PipeTarget.ToFile "stdout.txt")
Log.Information("Running '{path} {args}' in {dir}", command.TargetFilePath, command.Arguments, command.WorkingDirPath)
command
.ExecuteAsync()
.GetAwaiter()
.GetResult()
|> ignore