Cmdliner terms for ergonomic logging configuration
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cram: migrate tests to test/cram/ umbrella across the monorepo

Structural move per the new E521 rule and cram skill:

- Each package's cram tests now live under test/cram/, with shared
shell setup at test/cram/helpers.sh (auto-sourced by dune 3.21's
setup_scripts) and driver exes in test/cram/helpers/.
- Packages migrated: ocaml-git, ocaml-tty, ocaml-vlog, xdge,
ocaml-precommit, ocaml-publicsuffix, ocaml-requests, monopam, irmin.
- ocaml-tty's cram was actively broken; fixed and the driver rewritten
to use Tty.Progress.render.
- irmin: adds scrub_hash/scrub_time helper scripts for normalising
non-deterministic output (dune cram has no glob/regex matching).

+26 -31
+17 -17
test/cram/cli.t/run.t
··· 3 3 $ export NO_COLOR=1 4 4 5 5 Default: warning level, tracing silenced 6 - $ ../test_cli.exe 2>&1 6 + $ test_cli.exe 2>&1 7 7 test_cli.exe: [ERROR] error message 8 8 test_cli.exe: [WARNING] warning message 9 9 10 10 Quiet mode: errors only 11 - $ ../test_cli.exe -q 2>&1 11 + $ test_cli.exe -q 2>&1 12 12 test_cli.exe: [ERROR] error message 13 13 14 14 Verbose: info level 15 - $ ../test_cli.exe -v 2>&1 15 + $ test_cli.exe -v 2>&1 16 16 test_cli.exe: [ERROR] error message 17 17 test_cli.exe: [WARNING] warning message 18 18 test_cli.exe: [INFO] info message 19 19 20 20 Very verbose: debug level (tracing still silenced) 21 - $ ../test_cli.exe -vv 2>&1 21 + $ test_cli.exe -vv 2>&1 22 22 test_cli.exe: [ERROR] error message 23 23 test_cli.exe: [WARNING] warning message 24 24 test_cli.exe: [INFO] info message 25 25 test_cli.exe: [DEBUG] debug message 26 26 27 27 Triple verbose: debug + tracing enabled 28 - $ ../test_cli.exe -vvv 2>&1 28 + $ test_cli.exe -vvv 2>&1 29 29 test_cli.exe: [ERROR] error message 30 30 test_cli.exe: [WARNING] warning message 31 31 test_cli.exe: [INFO] info message ··· 33 33 test_cli.exe: [DEBUG] trace message 34 34 35 35 Using --log flag for global level 36 - $ ../test_cli.exe --log=error 2>&1 36 + $ test_cli.exe --log=error 2>&1 37 37 test_cli.exe: [ERROR] error message 38 38 39 - $ ../test_cli.exe --log=info 2>&1 39 + $ test_cli.exe --log=info 2>&1 40 40 test_cli.exe: [ERROR] error message 41 41 test_cli.exe: [WARNING] warning message 42 42 test_cli.exe: [INFO] info message 43 43 44 44 Using --log flag for per-source override 45 - $ ../test_cli.exe --log=warning,test:debug 2>&1 45 + $ test_cli.exe --log=warning,test:debug 2>&1 46 46 test_cli.exe: [ERROR] error message 47 47 test_cli.exe: [WARNING] warning message 48 48 test_cli.exe: [INFO] info message ··· 50 50 test_cli.exe: [DEBUG] trace message 51 51 52 52 Enable tracing via --log 53 - $ ../test_cli.exe --log=warning,test.tracing:debug 2>&1 53 + $ test_cli.exe --log=warning,test.tracing:debug 2>&1 54 54 test_cli.exe: [ERROR] error message 55 55 test_cli.exe: [WARNING] warning message 56 56 test_cli.exe: [DEBUG] trace message 57 57 58 58 Combined: global + per-source 59 - $ ../test_cli.exe --log=debug,test.tracing:warning 2>&1 59 + $ test_cli.exe --log=debug,test.tracing:warning 2>&1 60 60 test_cli.exe: [ERROR] error message 61 61 test_cli.exe: [WARNING] warning message 62 62 test_cli.exe: [INFO] info message 63 63 test_cli.exe: [DEBUG] debug message 64 64 65 65 Environment variable 66 - $ TEST_LOG=info ../test_cli.exe 2>&1 66 + $ TEST_LOG=info test_cli.exe 2>&1 67 67 test_cli.exe: [ERROR] error message 68 68 test_cli.exe: [WARNING] warning message 69 69 test_cli.exe: [INFO] info message 70 70 71 71 Help output shows all flags 72 - $ ../test_cli.exe --help=plain 2>&1 | grep -E '^\s+(-q|--quiet|-v|--verbose|--log|--json|--trace)' 72 + $ test_cli.exe --help=plain 2>&1 | grep -E '^\s+(-q|--quiet|-v|--verbose|--log|--json|--trace)' 73 73 --json 74 74 --log=SPEC (absent TEST_LOG env) 75 75 --log-tag=TAG ··· 78 78 -v, --verbose 79 79 80 80 JSON output: default level (warning) - includes app, hostname, pid 81 - $ ../test_cli.exe --json 2>&1 | sed 's/"timestamp":"[^"]*"/"timestamp":"..."/g; s/"hostname":"[^"]*"/"hostname":"..."/g; s/"pid":"[^"]*"/"pid":"..."/g' 81 + $ test_cli.exe --json 2>&1 | sed 's/"timestamp":"[^"]*"/"timestamp":"..."/g; s/"hostname":"[^"]*"/"hostname":"..."/g; s/"pid":"[^"]*"/"pid":"..."/g' 82 82 {"timestamp":"...","level":"error","source":"test","message":"error message","app":"test","hostname":"...","pid":"..."} 83 83 {"timestamp":"...","level":"warning","source":"test","message":"warning message","app":"test","hostname":"...","pid":"..."} 84 84 85 85 JSON output: verbose level 86 - $ ../test_cli.exe --json -v 2>&1 | sed 's/"timestamp":"[^"]*"/"timestamp":"..."/g; s/"hostname":"[^"]*"/"hostname":"..."/g; s/"pid":"[^"]*"/"pid":"..."/g' 86 + $ test_cli.exe --json -v 2>&1 | sed 's/"timestamp":"[^"]*"/"timestamp":"..."/g; s/"hostname":"[^"]*"/"hostname":"..."/g; s/"pid":"[^"]*"/"pid":"..."/g' 87 87 {"timestamp":"...","level":"error","source":"test","message":"error message","app":"test","hostname":"...","pid":"..."} 88 88 {"timestamp":"...","level":"warning","source":"test","message":"warning message","app":"test","hostname":"...","pid":"..."} 89 89 {"timestamp":"...","level":"info","source":"test","message":"info message","app":"test","hostname":"...","pid":"..."} 90 90 91 91 JSON output: with custom tags 92 - $ ../test_cli.exe --json --log-tag env=test --log-tag region=local 2>&1 | sed 's/"timestamp":"[^"]*"/"timestamp":"..."/g; s/"hostname":"[^"]*"/"hostname":"..."/g; s/"pid":"[^"]*"/"pid":"..."/g' 92 + $ test_cli.exe --json --log-tag env=test --log-tag region=local 2>&1 | sed 's/"timestamp":"[^"]*"/"timestamp":"..."/g; s/"hostname":"[^"]*"/"hostname":"..."/g; s/"pid":"[^"]*"/"pid":"..."/g' 93 93 {"timestamp":"...","level":"error","source":"test","message":"error message","app":"test","hostname":"...","pid":"...","env":"test","region":"local"} 94 94 {"timestamp":"...","level":"warning","source":"test","message":"warning message","app":"test","hostname":"...","pid":"...","env":"test","region":"local"} 95 95 96 96 JSON disabled: --json flag not exposed 97 - $ ../test_cli_no_json.exe --help=plain 2>&1 | grep -E '^\s+--json' || echo "no --json flag" 97 + $ test_cli_no_json.exe --help=plain 2>&1 | grep -E '^\s+--json' || echo "no --json flag" 98 98 no --json flag 99 99 100 - $ ../test_cli_no_json.exe -v 2>&1 100 + $ test_cli_no_json.exe -v 2>&1 101 101 test_cli_no_json.exe: [ERROR] error message 102 102 test_cli_no_json.exe: [WARNING] warning message 103 103 test_cli_no_json.exe: [INFO] info message
+4
test/cram/dune
··· 1 + (cram 2 + (applies_to :whole_subtree) 3 + (deps helpers/test_cli.exe helpers/test_cli_no_json.exe) 4 + (setup_scripts helpers.sh))
+2
test/cram/helpers.sh
··· 1 + #!/bin/sh 2 + export PATH="$PWD/../helpers:$PATH"
+3
test/cram/helpers/dune
··· 1 + (executables 2 + (names test_cli test_cli_no_json) 3 + (libraries vlog logs alcotest))
-14
test/dune
··· 1 1 (test 2 2 (name test) 3 - (modules test test_vlog) 4 3 (libraries vlog alcotest logs)) 5 - 6 - (executable 7 - (name test_cli) 8 - (modules test_cli) 9 - (libraries vlog logs alcotest)) 10 - 11 - (executable 12 - (name test_cli_no_json) 13 - (modules test_cli_no_json) 14 - (libraries vlog logs alcotest)) 15 - 16 - (cram 17 - (deps test_cli.exe test_cli_no_json.exe))