đź’˝ Gleam BR: Erlang Disk Log

Hex.pm HexDocs

A Type-Safe Gleam wrapper for the robust Erlang disk_log module. Designed for Telecom-grade Ring Buffers, high-performance event persistence, and extreme telemetry scenarios.

Overview

gbr_disk_log provides an idiomatic Gleam interface to Erlang’s built-in disk logging utility. It allows for efficient logging of binary data to disk with various rotation and repair strategies, ensuring that your application’s telemetry and event logs are handled with the same reliability as a Tier-1 telecom system.

When to use it? (Practical Examples)

Erlang’s disk_log was originally designed by Ericsson for Telecom systems to store massive amounts of Call Detail Records (CDRs) without crashing the nodes or indefinitely filling up the hard drives. In the Gleam ecosystem, it shines in scenarios such as:

Why use?

Limitations (When NOT to use it)

Transparency is key. gbr_disk_log is a highly specialized tool, not a silver bullet:

Installation

gleam add gbr_disk_log

Quickstart

import gbr/disk_log
import gleam/io

pub fn main() {
  // Configure and open a log
  let options =
    disk_log.options_empty
    |> disk_log.file("events.log")
    |> disk_log.type_(disk_log.Halt)
    |> disk_log.format(disk_log.External)

  let assert Ok(log) =
    disk_log.new("my_app_events")
    |> disk_log.open_options(options)

  // Log some data synchronously
  let assert Ok(_) = disk_log.log(log, <<"Hello, World!":utf8>>)

  // Log some data asynchronously
  let assert Ok(_) = disk_log.async_log(log, <<"Async event":utf8>>)

  // Sync data to disk
  let assert Ok(_) = disk_log.sync(log)

  // Get info about the log
  let assert Ok(info) = disk_log.info(log)
  io.println("Log file: " <> info.file)

  // Close the log
  let assert Ok(_) = disk_log.close(log)
}

Ecosystem

This package is part of the foundation of Gleam-BR and the gleam.dev.br ecosystem, focused on building high-performance, reliable P2P and edge computing solutions.

✨ Search Document