Commit Graph
190 Commits
Author SHA1 Message Date
Riccardo Manfrin 2af04119b9 Print Erlang levels in :console backend (#11304) 2021-10-09 16:56:30 +02:00
José Valim 459faff067 Use translator_inspect_opts for translating reports too
Closes #11223.
2021-09-03 22:36:17 +02:00
José Valim 19cf9eaa0e Add tests and update CHANGELOG 2021-04-09 13:07:16 +02:00
Łukasz Jan Niemier e4820862e3 Add functions for application wise log levels (#10854)
* feat: add functions application wise log levels

* test: add tests for setting level for multiple modules at once
2021-04-09 12:49:17 +02:00
José Valim 818af23bf1 Do not deadlock Logger if handler crashes on sync mode, closes #10420 2020-10-12 09:27:22 +02:00
José Valim faf1157020 Fix order dependent tests in logger suite 2020-10-08 09:43:45 +02:00
Daniil Fedotov f1f2d46ec8 Restrict Logger.configure on config_change callback (#10388)
The `config_change` callback is called from `application_controller` process,
which is receiving env updates on releases. `Logger.configure` does a blocking
call to the `Logger` process, which calls `Application.put_env`

This causes a crash on logger config update.

The fix is to call `Logger.configure` only for the config that have not yet
been persisted.
2020-10-03 08:25:15 +02:00
Enrico Rivarola 7eb29f5905 Include Erlang severity level to Logger metadata (#10300) 2020-09-03 09:48:13 +02:00
José Valim 2d9762f3f5 Use to_string chars on Logger.Formatter 2020-08-25 08:23:50 +02:00
Łukasz Jan Niemier 3b80c1b1e0 Properly handle GenServer message in logger translators (#10209)
When the logger report was in form of `%{label: term(), report: term()}`
the `report_cb` wasn't called and instead there was fall-back to the
"regular" formatter which could cause meaningless messages. This fixes
that by falling back to the "proper" `report_cb` in case when there was
no matching handler.
2020-07-28 16:39:17 +02:00
Mitchell Henke 75e5609364 include callers in translated Logger metadata for Task (#10111) 2020-06-19 20:50:48 +02:00
Wojtek Mach d2cb4f4063 Run formatter (#10090) 2020-06-09 22:49:27 +02:00
José Valim 5257bbe548 Make sure Logger.log/bare_log does not crash with :warn 2020-06-09 21:56:48 +02:00
Ryan Zidago 181c38f16e Fix Task PID and caller in Task Supervisor reports (#10025)
Closes #10024
2020-05-09 01:14:09 +02:00
José Valim 4a75716625 Improve docs and coverege for module levels 2020-02-29 09:20:26 +01:00
Łukasz Jan Niemier 2ce4e761c5 Expose functions for setting per-module levels (#9793) 2020-02-29 09:16:38 +01:00
Łukasz Jan Niemier 78c4192d31 Add structured logging (#9797) 2020-02-28 16:22:31 +01:00
José Valim d490c1297d Only print metadata of known types, closes #9814 2020-02-12 19:03:53 +01:00
Łukasz Jan Niemier 1fa3c45d1b Expose all logger levels (#9791) 2020-02-09 09:40:56 +01:00
Łukasz Jan Niemier 6311832079 fix(logger): use correct return value from report_cb/2 (#9798)
Earlier it assumed that the return type is the same as in `report_cb/1`
which is not true. `report_cb/1` returns format string and data while
`report_cb/2` returns already formatted string.
2020-02-09 09:34:34 +01:00
Wojtek Mach 480c3a30be Fix unused variable warnings (#9790) 2020-02-06 20:27:47 +01:00
Akash Hiremath 172fc603ed Fix logger truncate for multi-byte characters (#9767) 2020-01-31 10:44:30 +01:00
Eksperimental b0d4288174 Use titlecase in Elixir, Erlang, EEx, Unicode, and Dialyzer (#9557) 2019-11-19 09:10:29 +01:00
Łukasz Jan Niemier e7f0559255 Handle case when report_cb needs 2 arguments (#9478) 2019-11-03 21:11:11 +01:00
José Valim 02b29740b2 Filter more warnings and make filters less generic 2019-11-01 21:37:39 +01:00
José Valim 828be52841 Group log level tests 2019-11-01 19:54:05 +01:00
José Valim 59c5ba5e73 Ensure Logger config is properly reverted 2019-11-01 19:38:25 +01:00
José Valim d97a04e4fd Fix heisentest 2019-11-01 19:20:42 +01:00
José Valim a58bbc7141 Remove duplicated log level mapping 2019-11-01 19:14:08 +01:00
Łukasz Jan Niemier 4d0ccc7545 Translate logger level on startup (#9466) 2019-11-01 19:05:27 +01:00
Łukasz Jan Niemier 67dec4683d Use Erlang's logger as main logging implementation (#9333) 2019-11-01 15:53:05 +01:00
José Valim 9e8749b7c6 Allow start_options to be configured on Logger (#9438) 2019-10-24 00:03:50 +02:00
José Valim f1cfa523ff Discard metadata in the formatter rather than backend
Some formatters may want to format all of the metadata,
so we shouldn't forbid them of doing so.
2019-10-22 23:04:43 +02:00
José Valim 98e60a8425 Add v1.10-ready deprecations 2019-06-04 17:28:08 +02:00
Mitchell Henke 5f6113ba90 Translate process crash on node in Logger (#9020) 2019-05-07 10:20:50 +02:00
José Valim e90ebaecff Improve error on unknown backends 2019-03-05 14:16:33 +01:00
José Valim 6377b324ee Use a descentralized mode computation for Logger (#8567)
Previous logger versions would always compute the mode on the Logger
handler which meant that, if any other Logger handler blocked, either because
it was waiting on IO, the system is overloaded or due to long computations, a
burst of messages could make the Logger message queue grow quite large
until it notices it should change its mode.

This commit changes the computation to use a counter which is offset by
the current message length queue. This makes the following script go from
tens of thousands messages in the Logger inbox to only hundreds (assuming
a `sync_threshold` of 100) when writing a rate limited stdio with
`mix run foo.exs | pv -p -L 1k 1>/dev/null`:

```elixir
require Logger

# monitor memory
# :observer.start()

defmodule Loop do
  def run() do
    Logger.info(inspect(:crypto.strong_rand_bytes(1024)))
    Process.sleep(10)
    run()
  end
end

for _i <- 1..100 do
  spawn(fn ->
    Loop.run()
  end)
end

defmodule OtherLoop do
  def run() do
    IO.inspect(:stderr, Process.info(Process.whereis(Logger), :message_queue_len), [])
    IO.inspect(:stderr, :ets.tab2list(Logger.Config), [])
    Process.sleep(100)
    run()
  end
end

OtherLoop.run()
```
2019-01-05 17:31:54 +01:00
Bruce Park 8aeeb86dfe Improve Protocol.UndefinedError message... (#8579)
when passing the module name of a struct

Addresses https://github.com/elixir-lang/elixir/issues/8532
2019-01-02 13:08:37 +01:00
José Valim 95934e56c4 Add $callers tracking to Task (#8510)
This allows us to track which process invoked the Task
besides its ancestors in the supervision tree.

Closes #7995
2018-12-11 19:05:53 +01:00
José Valim ae644808dd No longer persist dynamically added logger backends (#8424)
Otherwise it is impossible to dynamically remove them,
which partially defeats the point of adding them dynamically
in the first place.

Therefore this commit moves the whole dynamic backend
management to the user.

Closes #8213
2018-11-26 14:36:11 +01:00
Ivan Mironov 0e8cd17043 Fix direct Logger.log call in case of compile_time_purge_matching logger option (#8391) 2018-11-20 17:43:56 +01:00
Eksperimental 52ac93dbf5 Use "shut down" when it is a verb (#8269) 2018-10-10 09:35:31 +02:00
José Valim 16e6aa6ca0 Optimize metadata merging and ensure no nil leakage (#7927)
Closes #7926
2018-07-18 19:35:13 +02:00
José Valim 36643e21ac Make sure Logger is flushed before reattaching, closes #7903 2018-07-14 22:33:40 +02:00
José Valim 94f3d60a26 Hard deprecate previously deprecated APIs 2018-07-12 12:44:03 +02:00
José Valim 35ac568044 Require Erlang/OTP 20+ 2018-07-12 12:12:00 +02:00
José Valim 1fe7847f0e Replace compile_time_purge_level by compile_time_purge_matching (#7847)
Now that we support a more general `compile_time_purge_matching`,
we can deprecate `compile_time_purge_level`. We chose the name
`:level_lower_than` rather than `:level` for the matching key
since all other matches are exact.
2018-07-10 19:28:52 +02:00
José Valim 02a327d3c4 Include initial_call and registered_name in metadata (#7844) 2018-07-09 14:27:30 +02:00
José Valim fd27c2053f Run the formatter on translator tests 2018-07-08 22:47:13 +02:00
José Valim c7d3552767 Include Logger metadata in crash reports 2018-07-08 22:37:36 +02:00