···11+# OCaml build artifacts
22+_build/
33+*.install
44+*.merlin
55+66+# Dune package management
77+dune.lock/
88+99+# Editor and OS files
1010+.DS_Store
1111+*.swp
1212+*~
1313+.vscode/
1414+.idea/
1515+1616+# Opam local switch
1717+_opam/
+21
LICENSE.md
···11+MIT License
22+33+Copyright (c) 2025 Thomas Gazagnaire
44+55+Permission is hereby granted, free of charge, to any person obtaining a copy
66+of this software and associated documentation files (the "Software"), to deal
77+in the Software without restriction, including without limitation the rights
88+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99+copies of the Software, and to permit persons to whom the Software is
1010+furnished to do so, subject to the following conditions:
1111+1212+The above copyright notice and this permission notice shall be included in all
1313+copies or substantial portions of the Software.
1414+1515+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121+SOFTWARE.
+102
README.md
···11+# vlog
22+33+Cmdliner terms for ergonomic logging configuration.
44+55+## Overview
66+77+**vlog** provides cmdliner terms that configure the OCaml [Logs](https://erratique.ch/software/logs) library with a familiar CLI interface inspired by common Unix tools and Rust's `RUST_LOG` pattern.
88+99+## Features
1010+1111+- **Verbosity flags**: `-q`, `-v`, `-vv`, `-vvv`
1212+- **RUST_LOG-style configuration**: `--log=level,src:level,...`
1313+- **JSON output**: `--json` for structured logging
1414+- **Protocol tracing**: `--trace FILE` to capture `*.tracing` sources
1515+- **Environment variable**: `<APP>_LOG` (e.g., `MYAPP_LOG`)
1616+1717+## Installation
1818+1919+```
2020+opam install vlog
2121+```
2222+2323+## Usage
2424+2525+```ocaml
2626+open Cmdliner
2727+2828+let run _config =
2929+ Logs.info (fun m -> m "Starting...");
3030+ (* your code *)
3131+3232+let cmd =
3333+ let info = Cmd.info "myapp" in
3434+ Cmd.v info Term.(const run $ Vlog.setup "myapp")
3535+3636+let () = exit (Cmd.eval cmd)
3737+```
3838+3939+### Command Line
4040+4141+```bash
4242+myapp -q # errors only
4343+myapp # warnings (default)
4444+myapp -v # info level
4545+myapp -vv # debug level
4646+myapp -vvv # debug + protocol tracing
4747+4848+myapp --log=debug # set level via flag
4949+myapp --log=info,http:debug # global info, http at debug
5050+myapp --log=warn,tls.tracing:debug # enable specific tracing
5151+5252+MYAPP_LOG=debug myapp # set level via env var
5353+5454+myapp --json # JSON output
5555+myapp --trace protocol.log # write traces to file
5656+```
5757+5858+### Verbosity Levels
5959+6060+| Flag | Level | `*.tracing` sources |
6161+|--------|---------|---------------------|
6262+| `-q` | Error | Silenced |
6363+| (none) | Warning | Silenced |
6464+| `-v` | Info | Silenced |
6565+| `-vv` | Debug | Silenced |
6666+| `-vvv` | Debug | Enabled |
6767+6868+The `-vv` flag gives you application-level debug output without the noisy protocol hexdumps. Use `-vvv` or `--trace FILE` when you need full protocol tracing.
6969+7070+### JSON Output
7171+7272+With `--json`, use the optional `json_reporter` parameter to enable JSON log output:
7373+7474+```ocaml
7575+let cmd =
7676+ let info = Cmd.info "myapp" in
7777+ Cmd.v info Term.(const run $ Vlog.setup ~json_reporter:Json_logs.reporter "myapp")
7878+```
7979+8080+Requires the `json-logs` package.
8181+8282+## API
8383+8484+- `Vlog.setup` - Main cmdliner term combining all flags
8585+- `Vlog.quiet` - Term for `-q`/`--quiet`
8686+- `Vlog.verbosity` - Term for `-v`/`--verbose`
8787+- `Vlog.log_term` - Term for `--log` with env var
8888+- `Vlog.json` - Term for `--json`
8989+- `Vlog.trace_file` - Term for `--trace FILE`
9090+- `Vlog.parse_log_spec` - Parse RUST_LOG-style spec
9191+- `Vlog.apply_source_overrides` - Apply per-source levels
9292+- `Vlog.configure_tracing_sources` - Enable/disable `*.tracing` sources
9393+9494+## Related Work
9595+9696+- [logs.cli](https://erratique.ch/software/logs) - Basic cmdliner integration in the Logs library. Provides `--verbosity` and `-v` flags. vlog extends this with RUST_LOG-style per-source control, JSON output, and protocol tracing.
9797+- [env_logger](https://docs.rs/env_logger/) (Rust) - The inspiration for the `--log` flag syntax and `<APP>_LOG` environment variable pattern.
9898+- [debug](https://www.npmjs.com/package/debug) (Node.js) - Popular namespace-based debug logging. Similar concept of per-source control.
9999+100100+## License
101101+102102+MIT License. See [LICENSE.md](LICENSE.md) for details.