package echo
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
md5=f21fc179d03f16acc57b6e1d844993fb
sha512=7bd62891dedf1b2d7f39d07ea6b58266bcc62d4ccd667931f8fb51d8767cd3b2238a567adf89b173f9c0f7d246a62893cc237a91b8c60e6899ef53715f0ad376
Description
Echo is a lightweight logging library for OCaml with C lib bindings, allowing both OCaml and C code to emit structured log messages through a unified logging interface.
README
Echo
Echo is a lightweight logging library for OCaml with C lib bindings, allowing both OCaml and C code to emit structured log messages through a unified logging interface.

Features
- C bindings for easy logging integration with your C lib (see C API section below)
- Supports output to
stdout,stderr, and .log files - Standard log levels:
TRACE,INFO,WARN,ERROR,FATAL - Manual flushing of logs
Installation
Echo can be installed with opam:
opam install echoopam package page: https://opam.ocaml.org/packages/echo
API Overview
OCaml
val set_out : out_type -> unit
val trace : ('a, unit, string, unit) format4 -> 'a
val info : ('a, unit, string, unit) format4 -> 'a
val warn : ('a, unit, string, unit) format4 -> 'a
val error : ('a, unit, string, unit) format4 -> 'a
val fatal : ('a, unit, string, unit) format4 -> 'a
val flush : unit -> unitC
Don't forget to #include <echo.h>
void echo_trace(const char *fmt, ...);
void echo_info(const char *fmt, ...);
void echo_warn(const char *fmt, ...);
void echo_error(const char *fmt, ...);
void echo_fatal(const char *fmt, ...);Example Usage
In OCaml
let main () =
(* Optional: Redirect logs to a file *)
Echo.set_out (File "debug.log");
(* Log from OCaml *)
Echo.trace "Starting analysis of '%s'" "report.csv";
Echo.info "Processed %d items" 42;
Echo.warn "Unusual delay: %.2f ms" 123.45;
Echo.error "Failed to read file '%s'" "data.bin";
Echo.fatal "Unrecoverable crash in module '%s'" "engine";
Echo.flush ()
let () = main ()In C
#include "echo.h"
void dummie_c_fn()
{
echo_trace("%s", "message");
echo_info("%s", "message");
echo_warn("%s", "message");
echo_error("%s", "message");
echo_fatal("%s", "message");
}License
MIT License — free to use, modify, and distribute.
Contributions
Contributions are welcome! Feel free to open issues or submit PRs if you find bugs or have ideas for improvement.
Dependencies (8)
Dev Dependencies (1)
-
odoc
with-doc
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building echo with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.0.5 (this version) | n/a | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure