xadhoom

xadhoom

Logbook - a tag/category based logger

I’ve published to hex Logbook, our Logger wrapper that’we use on a couple of rather big projects. Has been around since early 2019, but just now added to hex.pm

GitHub Repo: GitHub - VoiSmart/logbook: Another opinionated logger for Elixir, with the addition of tag/module based logging. · GitHub
Docs: Logbook — logbook v4.0.0
Hex.pm: logbook | Hex

Basically is a Logger wrapper that adds categories (or tags) to each logger entry, and each tag can have it’s own log level. As a bonus, module names are automatically tracked as tags and a specific log level can be set for them, too.

Intended usage: activate a specific log level for a specific module only, or a specific log level for a tag (or a group of tags) that may spread across different modules.

By design, the “global” Elixir Logger level still wins: you cannot activate a debug level for a tag and have it emitted if the global Logger level is higher (set on :error for example). But if all the codebase uses Logbook instead of Logger this is not really a problem.

We built it because on our large application, we have different subsystems running, and just enabling a more verbose logger level is a no-go, since too many logs are emitted and is difficult to follow what is going on (or puts too much pressure on the Logger reducing overall performances). With Logbook we can nail down what we want to see and investigate more freely.

The library is pretty solid, is running in production on several systems since the beginning.

Most Liked

hauleth

hauleth

Since Elixir 1.10 you can do it on per-module basis via:

:logger.set_module_level(Mod, level)

And since 1.11 it is also exposed via Logger API as:

Logger.put_module_level(Mod, level)

There are also 2 “meta levels” :all and :none. Their behaviour should be rather obvious.

Also similar thing can be achieved via setting :domain in metadata and then using :logger.add_primary_filter/2.

xadhoom

xadhoom

Thanks! This was done before 1.10 so was needed. But I think now we can leverage on the official APIs for the module level part.

Well, like above we started with v1.9. But still, having to dynamically filter based on the :domains (currently we keep track of that on a ETS table) means doing something similar to what we already do (attach/remove a filter on the fly). Still, I’m not sure if the :domains means the sames as tags, I see tags more specific inside a domain.

Said that, since we now require Elixir v1.11+ in Logbook v2, I think something can be adapted to use the official APIs, especially for the module parts.

thanks for pointers!

Where Next?

Popular in Announcing Top

seancribbs
Today I released a new dialyzer Mix task as the dialyzex package! At the time we started writing this task, the existing dialyzer integra...
New
ostinelli
Let’s write a database! Well not really, but I think it’s a little sad that there doesn’t seem to be a simple in-memory distributed KV da...
New
mikehostetler
I’m excited to announce Jido, a framework providing foundational primitives for building autonomous agent systems in Elixir. While develo...
New
bryanjos
Hi, I wanted share a small library we at Revelry Labs made for rendering react components from the server side. There are instructions fo...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 12560 134
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
fuelen
Hey folks! Want to present a toolkit for writing command-line user interfaces. It provides a convenient interface for colorizing text...
New
marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement