package echo
A minimal interop OCaml + C logging solution
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.0.5.tar.gz
md5=f21fc179d03f16acc57b6e1d844993fb
sha512=7bd62891dedf1b2d7f39d07ea6b58266bcc62d4ccd667931f8fb51d8767cd3b2238a567adf89b173f9c0f7d246a62893cc237a91b8c60e6899ef53715f0ad376
doc/README.html
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 echo
opam
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 -> unit
C
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.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page