Commit Graph
199 Commits
Author SHA1 Message Date
bbhoss cb2fd9db38 Add support for ports in Logger metadata (#12332)
Resolves #12328
2023-01-12 00:26:56 +01:00
sabiwara 29bf449f3f Evaluate formating charlists as ~c sigils (#12064) 2022-08-10 06:47:00 +02:00
José Valim 76a683f41c Add deprecations 2022-07-27 17:18:53 +02:00
José Valim 1b60acbe9e Allow LINE to be set for tests 2022-07-18 09:58:14 +02:00
José Valim 4b34231fb1 Allow :warning to configure Logger Console color 2022-05-15 23:30:44 +02:00
José Valim 4da2f8de7a Use :warning level for Logger threshold 2022-05-15 23:27:51 +02:00
Stefan Chrobot 7269438372 Add Logger.put_process_level/2 and rewrite enable/1 and disable/1 (#11691) 2022-03-10 10:16:22 +01:00
Jinkyou Son (Json) f4d14047f0 Deprecate levelpad of Logger.Formatter (#11633) 2022-02-17 08:17:40 +01:00
Eksperimental b5692822b1 Use ERTS instead of erts (#11362) 2021-11-04 08:18:19 +01:00
Riccardo Manfrin 56cfb4fedc Print Erlang levels in :console backend (#11304) 2021-10-09 16:56:30 +02:00
José Valim cf3e26048b Use translator_inspect_opts for translating reports too
Closes #11223.
2021-09-03 22:36:17 +02:00
José Valim d5b114a79c Add tests and update CHANGELOG 2021-04-09 13:07:16 +02:00
Łukasz Jan Niemier 9a0dba97e6 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 3becc7eb25 Do not deadlock Logger if handler crashes on sync mode, closes #10420 2020-10-12 09:27:22 +02:00
José Valim 0187efb423 Fix order dependent tests in logger suite 2020-10-08 09:43:45 +02:00
Daniil Fedotov c1ed14b17e 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 a19d8f05e6 Include Erlang severity level to Logger metadata (#10300) 2020-09-03 09:48:13 +02:00
José Valim 89e12d0737 Use to_string chars on Logger.Formatter 2020-08-25 08:23:50 +02:00
Łukasz Jan Niemier f49829d501 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 291f5e41f2 include callers in translated Logger metadata for Task (#10111) 2020-06-19 20:50:48 +02:00
Wojtek Mach cba3f3ae10 Run formatter (#10090) 2020-06-09 22:49:27 +02:00
José Valim 1a2ec64a5c Make sure Logger.log/bare_log does not crash with :warn 2020-06-09 21:56:48 +02:00
Ryan Zidago 8fa9b0d954 Fix Task PID and caller in Task Supervisor reports (#10025)
Closes #10024
2020-05-09 01:14:09 +02:00
José Valim 212b0c41da Improve docs and coverege for module levels 2020-02-29 09:20:26 +01:00
Łukasz Jan Niemier 9fd97c2d29 Expose functions for setting per-module levels (#9793) 2020-02-29 09:16:38 +01:00
Łukasz Jan Niemier 3782b4b70e Add structured logging (#9797) 2020-02-28 16:22:31 +01:00
José Valim de65e94ef6 Only print metadata of known types, closes #9814 2020-02-12 19:03:53 +01:00
Łukasz Jan Niemier 4da85d8400 Expose all logger levels (#9791) 2020-02-09 09:40:56 +01:00
Łukasz Jan Niemier 5207a2b816 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 da447cf011 Fix unused variable warnings (#9790) 2020-02-06 20:27:47 +01:00
Akash Hiremath ab05aa8d4a Fix logger truncate for multi-byte characters (#9767) 2020-01-31 10:44:30 +01:00
Eksperimental 0acab05f53 Use titlecase in Elixir, Erlang, EEx, Unicode, and Dialyzer (#9557) 2019-11-19 09:10:29 +01:00
Łukasz Jan Niemier 0c45373026 Handle case when report_cb needs 2 arguments (#9478) 2019-11-03 21:11:11 +01:00
José Valim 8545d41149 Filter more warnings and make filters less generic 2019-11-01 21:37:39 +01:00
José Valim 7954e80257 Group log level tests 2019-11-01 19:54:05 +01:00
José Valim 135b753d93 Ensure Logger config is properly reverted 2019-11-01 19:38:25 +01:00
José Valim 07087ab8ad Fix heisentest 2019-11-01 19:20:42 +01:00
José Valim 6fd99b0e62 Remove duplicated log level mapping 2019-11-01 19:14:08 +01:00
Łukasz Jan Niemier 17059ddb29 Translate logger level on startup (#9466) 2019-11-01 19:05:27 +01:00
Łukasz Jan Niemier f128ae3d7a Use Erlang's logger as main logging implementation (#9333) 2019-11-01 15:53:05 +01:00
José Valim 89a57a876c Allow start_options to be configured on Logger (#9438) 2019-10-24 00:03:50 +02:00
José Valim c708d26430 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 d65f8bb6e4 Add v1.10-ready deprecations 2019-06-04 17:28:08 +02:00
Mitchell Henke 53e2854dc1 Translate process crash on node in Logger (#9020) 2019-05-07 10:20:50 +02:00
José Valim e13bb2e4de Improve error on unknown backends 2019-03-05 14:16:33 +01:00
José Valim 41756b6e9d 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 f046675ed1 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 8f5adcd27b 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 61d38a0505 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 6fb3ef32e8 Fix direct Logger.log call in case of compile_time_purge_matching logger option (#8391) 2018-11-20 17:43:56 +01:00