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
Docs: Logbook — logbook v2.0.1
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 Libraries Top

scohen
Lexical Lexical is a next-generation language server for the Elixir programming language. Features Context aware code completion As-you...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
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
cjen07
parameterized pipe in elixir: |n> edit: negative index in |n> and mixed usage with |> are supported example: use ParamP...
New
archan937
It is a well-know topic within the Elixir community: “To mock or not to mock? :)” Every alchemist probably has his / her own opinion con...
New
danschultzer
In short Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependen...
New
zorbash
I created Kitto a framework for dashboards inspired by Dashing. [demo] The distributed characteristics of Elixir and the low memory foo...
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
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
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
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
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New

Sub Categories:

We're in Beta

About us Mission Statement