pine/README.md
wqtt 0983484bc0
Some checks failed
test / test (push) Failing after 33s
chore(docs): fix code example
2024-07-30 00:50:09 -04:00

84 lines
1.7 KiB
Markdown

# pine
![](./pine.svg)
[![Package Version](https://img.shields.io/hexpm/v/pine)](https://hex.pm/packages/timber)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/pine/)
```sh
gleam add pine
```
```gleam
import pine
pub fn main() {
// The defaults work out of the box.
// This will print a line to the console.
pine.new()
|> pine.info("hello world!")
// info <unix millis> hello world!
// Pine is configurable!
pine.new()
// You can set the level.
|> pine.set_level(pine.level_info())
// As well as the format.
|> pine.set_format(pine.format_json())
// And finally, the transport!
|> pine.set_transport(pine.transport_file("logs.txt"))
// Different log functions are on the pine module.
pine.new()
// You have access to "debug" logs
|> pine.debug("debug message")
// As well as 'info' logs
|> pine.info("info message")
// As well as 'warn' logs
|> pine.warn("warn message")
// As well as 'err' logs
|> pine.err("err message")
// You can add attributes to loggers as needed.
// This is especially useful for telemetry and tracing.
pine.new()
// Such as strings
|> pine.with_string("version", "v1.0.2")
// Or ints
|> pine.with_int("page_views", 69)
// Or floats
|> pine.with_float("opacity", 0.89)
// or bools
|> pine.with_bool("checked_balance", False)
// then see them all in action
|> pine.info("hello world!")
// info <unix millis> hello world! version=v1.0.2 page_views=69 opacity=0.89 checked_balance=False
}
```
Further documentation can be found at <https://hexdocs.pm/pine>.
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
```