Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/secomind/pretty_log
An Elixir log formatter library.
https://github.com/secomind/pretty_log
elixir elixir-library logfmt logging
Last synced: 3 months ago
JSON representation
An Elixir log formatter library.
- Host: GitHub
- URL: https://github.com/secomind/pretty_log
- Owner: secomind
- License: apache-2.0
- Created: 2019-10-08T10:14:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-11T01:31:58.000Z (over 3 years ago)
- Last Synced: 2024-09-18T11:56:21.555Z (5 months ago)
- Topics: elixir, elixir-library, logfmt, logging
- Language: Elixir
- Homepage:
- Size: 71.3 KB
- Stars: 9
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PrettyLog
PrettyLog is an Elixir library which provides some ready-to-use log formatters, including a Logfmt formatter.
## Installation
- Add `:pretty_log` dependency to your project's `mix.exs`:```elixir
def deps do
[
{:pretty_log, "~> 0.1"}
]
end
```
- Run `mix deps.get`## Using PrettyLog
Just change the `:format` config entry in your config/{prod,dev,test}.exs files:
```elixir
-config :logger, :console, format: "[$level] $message\n"
+config :logger, :console,
+ format: {PrettyLog.LogfmtFormatter, :format},
+ metadata: [:module, :request_id, :tag]
```metadata is arbitrary and optional.
You may change the default key names via the following config options, values must be atoms:
```elixir
config :pretty_log,
:timestamp_key_name, :when, # defaults to :ts
:level_key_name, :severity, # defaults to :level
:message_key_name, :humans, # defaults to :msg
```## Available Formatters
Following formatters are included:
- PrettyLog.LogfmtFormatter
- PrettyLog.UserFriendlyFormatter## Formatter Vs Backend
Formatter and logger backend are two distinct components.
- The formatter transforms a log message and its metadata into a binary
- The logger backend outputs log binariesThis library is focused on logs formatting, leaving to you the choice about your favourite backend.
## About This Project
This project has been created in order to provide better logs in [Astarte](https://github.com/astarte-platform/astarte).
We are open to any contribution and we encourage adoption of this library, also outside Astarte, in order to provide better logs to everyone.