pine/README.md

84 lines
1.7 KiB
Markdown
Raw Normal View History

2024-07-30 03:56:45 +00:00
# pine
2024-07-30 04:40:16 +00:00
![](./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.
2024-07-30 04:50:09 +00:00
|> pine.set_level(pine.level_info())
2024-07-30 04:40:16 +00:00
// As well as the format.
2024-07-30 04:50:09 +00:00
|> pine.set_format(pine.format_json())
2024-07-30 04:40:16 +00:00
// 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!")
2024-07-30 04:50:09 +00:00
// info <unix millis> hello world! version=v1.0.2 page_views=69 opacity=0.89 checked_balance=False
2024-07-30 04:40:16 +00:00
}
```
Further documentation can be found at <https://hexdocs.pm/pine>.
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
```