jeramyRR

jeramyRR

Compile time purging of logger levels

Why does elixir purge logging statements at compile time? I know you have to indicate what level you’d like to purge in the config, but doesn’t this take away the ability to temporarily increase logging in production if something goes wrong?

Most Liked

aseigo

aseigo

Cycles are cycles. And when you have a million connections being handled by your application, those cycles add up. I’ve seen the same thing with C/C++ code bases, including ones where methods that were slow were improved by conditionally compiling out logging output that was disabled at runtime with configuration.

The fact that you can reclaim those cycles by compiling the calls right out does not equal “calls to Logger are horribly slow”. I honestly don’t know how slow they are (I don’t have numbers on that), but you could always take Benchee and wrap it around a large number of Logger calls which do not hit the backend and find out.

As for the cost of native calls: they are quite cheap: Latency of Native Functions for Erlang and Elixir · potatosalad

OvermindDL1

OvermindDL1

For note, there’s a reason every language with high-performance logging libraries has ‘some’ way to remove logging calls entirely if the language allows for it as even a simple global boolean check can have too high of an overhead in high-performance applications. Plus on the BEAM it’s not like it’s hard to add even brand-new logging statements to a running system, hot-swapping is easy.

sneako

sneako

I’m pretty sure that was a new feature of 1.7. if you look at the docs for 1.6 here Logger – Logger v1.6.0, you’ll find: " The Logger macros also accept messages as strings, but keep in mind that strings are always evaluated regardless of log-level. As such, it is recommended to use a function whenever the message is expensive to compute." As stated by @NobbZ

Where Next?

Popular in Discussions Top

Jayshua
I recently came across the javascript library htmx. It reminded me a lot of liveview so I thought the community here might be interested....
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New
Ankhers
Just a little information upfront. Generally speaking, if I feel like I need to either break a pipe chain or use an anonymous function in...
New
nunobernardes99
Hi there Elixir friends :vulcan_salute: In a recent task I was on, I needed to check in two dates which of them is the maximum and which...
New
New
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
wmnnd
The Go vs Elixir thread got me thinking: Would it be too hard to implement a simple mechanism for creating Go-style static app binaries f...
New
pdgonzalez872
If this has been asked here before, please point me to where it was asked as I didn’t find it when I searched the forum. Maybe a mailing ...
New
MarioFlach
Hello, I want to share a project I’ve been working on for a while: https://github.com/almightycouch/gitgud Background Some time ago I ...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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
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
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
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

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement