plugins/ocaml-dev/skills/logs/SKILL.md
OCaml Logs library patterns for structured logging. Use when Claude needs to: (1) Add logging to OCaml modules, (2) Create per-module log sources, (3) Use appropriate log levels, (4) Add structured tags to log messages
npx skillsauth add avsm/ocaml-claude-marketplace logsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The logs library provides structured logging with per-module sources.
Every module that logs should create its own source:
let log_src = Logs.Src.create "project.module_name"
module Log = (val Logs.src_log log_src : Logs.LOG)
This is the standard idiom. Do NOT attempt to abstract or deduplicate this boilerplate.
| Level | Function | Use Case |
|-------|----------|----------|
| App | Log.app | Always shown to user (startup, completion) |
| Error | Log.err | Handled but critical errors |
| Warning | Log.warn | Potential issues, operation continues |
| Info | Log.info | State transitions, progress |
| Debug | Log.debug | Verbose debugging details |
Log.info (fun m -> m "Processing %d items" count);
Log.err (fun m -> m "Failed to connect: %s" reason);
Log.debug (fun m -> m "Request: %a" Request.pp req)
Add context with tags for filtering/analysis:
Log.info (fun m ->
m "Event received: %s" event_type
~tags:(Logs.Tag.add "channel_id" channel Logs.Tag.empty))
In CLI applications, set up the reporter in bin/common.ml:
let setup_log style_renderer level =
Fmt_tty.setup_std_outputs ?style_renderer ();
Logs.set_level level;
Logs.set_reporter (Logs_fmt.reporter ())
open Cmdliner
let setup_log =
Term.(const setup_log
$ Fmt_cli.style_renderer ()
$ Logs_cli.level ())
tools
Working with the OxCaml extensions to OCaml. Use when the oxcaml compiler is available and you need high-performance, unboxing, stack allocation, data-race-free parallelism
development
Creating OCaml library tutorials using .mld documentation format with MDX executable examples. Use when discussing tutorials, documentation, .mld files, MDX, or interactive documentation.
development
Testing strategies for OCaml libraries. Use when discussing tests, alcotest, eio mocks, test structure, or test-driven development in OCaml projects.
development
Security hardening for OCaml libraries through systematic vulnerability research. Use when Claude needs to: (1) Research CVEs in similar implementations (C, Rust, Go, Python) and add regression tests, (2) Add fuzz tests for parsers and encoders, (3) Audit integer handling and buffer operations, (4) Test boundary conditions and malformed input, (5) Review cryptographic usage, (6) Add defensive checks against common vulnerability classes