Packages

Structured Pooka logging on Erlang/OTP Logger

Current section

Files

Jump to
loggit README.md
Raw

README.md

# Loggit

[![Package Version](https://img.shields.io/hexpm/v/loggit?style=for-the-badge&color=75618E)](https://hex.pm/packages/loggit)
[![Hex Docs](https://img.shields.io/website?url=https%3A%2F%2Floggit.hexdocs.pm%2F&style=for-the-badge&label=hex&up_message=docs&up_color=FF891F&down_message=not%20found&down_color=lightgrey)](https://loggit.hexdocs.pm/)
[![Tests](https://img.shields.io/github/actions/workflow/status/peregrinefinch/loggit/test.yml?branch=main&style=for-the-badge&label=tests)](https://github.com/peregrinefinch/loggit/actions/workflows/test.yml)

Loggit sends Pooka events to [Erlang/OTP Logger](https://www.erlang.org/doc/apps/kernel/logger.html).
It adds a console formatter and a typed, bounded event collector for integrations
such as an error tracker.

```pooka
module main

import loggit.{Colour, Level}

main() {
  let assert Ok(_) = loggit.install_console(Colour.Auto)
  let assert Ok(_) = loggit.set_level(Level.Info)
  loggit.log(Level.Info, "request served", [
    #("request_id", "req-42"),
    #("route", "/books")
  ])
}
```

The default console prints a short line such as `[info] request served`.
For UTC timestamps, fields, and stack frames, call
`loggit.install_console_with_style(Colour.Auto, ConsoleStyle.Detailed)`
with `ConsoleStyle` imported. Structured collectors receive the full event
with either format.

See [the integration guide](docs/integration.md) for scoped fields, native OTP
crashes and collector behaviour.

## Licence

Licensed under the [Apache License, Version 2.0](LICENSE).