package echo
A minimal interop OCaml + C logging solution
Install
Dune Dependency
Authors
Maintainers
Sources
v0.0.4.tar.gz
md5=1608c06b7d83c9c3b99c6163071f23b3
sha512=2e299ab12cecabe78011fc56177021d1240fbbc983569acf9ee4736b3c0c8b7cc4023c4b840cfb6a9b5ee6a7f2687459dca4c081aee351956c6f7fc972106459
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
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