-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: lake: CLI options to control output & failure log levels
- Loading branch information
Showing
14 changed files
with
167 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Lean.Elab.Command | ||
run_cmd Lean.logError "foo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Lean.Elab.Command | ||
run_cmd Lean.logInfo "foo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Lean.Elab.Command | ||
run_cmd Lean.logWarning "foo" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Lake | ||
open Lake DSL | ||
|
||
package test | ||
|
||
/- | ||
Test logging in Lake CLI | ||
-/ | ||
|
||
def cfgLogLv? := (get_config? log).bind LogLevel.ofString? | ||
|
||
meta if cfgLogLv?.isSome then | ||
run_cmd Lean.log "bar" cfgLogLv?.get!.toMessageSeverity | ||
|
||
|
||
/- | ||
Test logging in Lean | ||
-/ | ||
|
||
lean_lib Log | ||
|
||
/- | ||
Test logging in job | ||
-/ | ||
|
||
def top (level : LogLevel) : FetchM (BuildJob Unit) := Job.async do | ||
logEntry {level, message := "foo"} | ||
return ((), .nil) | ||
|
||
target topTrace : Unit := top .trace | ||
target topInfo : Unit := top .info | ||
target topWarning : Unit := top .warning | ||
target topError : Unit := top .error | ||
|
||
/-- | ||
Test logging in build helper | ||
-/ | ||
|
||
def art (pkg : Package) (level : LogLevel) : FetchM (BuildJob Unit) := Job.async do | ||
let artFile := pkg.buildDir / s!"art_{level}" | ||
(((), ·)) <$> buildFileUnlessUpToDate artFile .nil do | ||
logEntry {level, message := "foo"} | ||
createParentDirs artFile | ||
IO.FS.writeFile artFile "" | ||
|
||
target artTrace pkg : Unit := art pkg .trace | ||
target artInfo pkg : Unit := art pkg .info | ||
target artWarning pkg : Unit := art pkg .warning | ||
target artError pkg : Unit := art pkg .error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
LAKE=${LAKE:-../../.lake/build/bin/lake} | ||
|
||
./clean.sh | ||
|
||
# Test failure log level | ||
|
||
log_fail_target() { | ||
($LAKE build "$@" && exit 1 || true) | grep --color foo | ||
($LAKE build "$@" && exit 1 || true) | grep --color foo # test replay | ||
} | ||
|
||
log_fail_target topTrace --fail-level=trace | ||
log_fail_target artTrace --fail-level=trace | ||
|
||
log_fail() { | ||
lv=$1; shift | ||
log_fail_target top${lv^} "$@" | ||
log_fail_target art${lv^} "$@" | ||
log_fail_target Log.${lv^} "$@" | ||
} | ||
|
||
log_fail info --iofail | ||
log_fail warning --wfail | ||
log_fail error | ||
|
||
# Test output log level | ||
|
||
log_empty() { | ||
lv=$1; shift | ||
rm -f .lake/build/art_$lv | ||
$LAKE build art${lv^} "$@" | grep --color foo && exit 1 || true | ||
$LAKE build art${lv^} -v # test whole log was saved | ||
$LAKE build art${lv^} "$@" | grep --color foo && exit 1 || true # test replay | ||
} | ||
|
||
log_empty info -q | ||
log_empty info --log-level=warning | ||
log_empty warning --log-level=error | ||
|
||
log_empty trace -q | ||
log_empty trace --log-level=info | ||
log_empty trace | ||
|
||
# Test configuration-time output log level | ||
|
||
$LAKE resolve-deps -R -Klog=info 2>&1 | grep --color "info: bar" | ||
$LAKE resolve-deps -R -Klog=info -q 2>&1 | | ||
grep --color "info: bar" && exit 1 || true | ||
$LAKE resolve-deps -R -Klog=warning 2>&1 | grep --color "warning: bar" | ||
$LAKE resolve-deps -R -Klog=warning --log-level=error 2>&1 | | ||
grep --color "warning: bar" && exit 1 || true |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.