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

tmbb
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
asiniy
Hey there! I wrote a download elixir package which does exactly what its name about - an easy way to download files. I saw solutions ab...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
Jskalc
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue. It’s a seamless integration of Vue and Phoenix LiveView, i...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
anshuman23
Hello all, I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New
mattludwigs
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 10858 107
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
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
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement