Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/larzconwell/flash
Flash is a Gleam package enabling structured logging in both Erlang and JavaScript environments
https://github.com/larzconwell/flash
gleam logging
Last synced: 3 months ago
JSON representation
Flash is a Gleam package enabling structured logging in both Erlang and JavaScript environments
- Host: GitHub
- URL: https://github.com/larzconwell/flash
- Owner: larzconwell
- License: other
- Created: 2024-03-05T13:23:30.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-23T19:41:15.000Z (8 months ago)
- Last Synced: 2024-03-30T13:23:28.541Z (8 months ago)
- Topics: gleam, logging
- Language: Gleam
- Homepage: https://hexdocs.pm/flash
- Size: 13.7 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gleam - flash - [📚](https://hexdocs.pm/flash/) - Gleam package enabling structured logging in both Erlang and JavaScript environments (Packages / Logging and Monitoring)
README
# flash
[![Package Version](https://img.shields.io/hexpm/v/flash)](https://hex.pm/packages/flash)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/flash/)
[![License](https://img.shields.io/badge/License-BSD_2--Clause_+_Patent-blue.svg)](https://github.com/larzconwell/flash/blob/main/LICENSE)
[![Test](https://github.com/larzconwell/flash/actions/workflows/test.yml/badge.svg)](https://github.com/larzconwell/flash/actions)`flash` is a Gleam package enabling structured logging in both Erlang and JavaScript environments.
## Usage
```
gleam add flash
```With the default text writer output:
```gleam
import flash.{InfoLevel, GroupAttr, StringAttr}pub fn main() {
flash.new(InfoLevel, flash.text_writer)
|> flash.with_group("request")
|> flash.with_attrs([
StringAttr("method", "POST"),
StringAttr("path", "/user/create"),
StringAttr("id", "foobar"),
])
|> flash.info("request")
}
``````
21:24:12 INFO request request.id=foobar request.method=POST request.path=/user/create
```With the default json writer output:
```gleam
import flash.{InfoLevel, GroupAttr, StringAttr}pub fn main() {
flash.new(InfoLevel, flash.json_writer)
|> flash.with_group("request")
|> flash.with_attrs([
StringAttr("method", "POST"),
StringAttr("path", "/user/create"),
StringAttr("id", "foobar"),
])
|> flash.info("request")
}
``````
{"level":"info","time":"2024-03-12T21:25:03.022-04:00","message":"request","request":{"id":"foobar","method":"POST","path":"/user/create"}}
```## Developing
```shell
ln -s $(pwd)/.hooks/pre-commit .git/hooks/pre-commit
gleam format
gleam build
gleam test
```