Yes, it should, specially now that the flush implementation has changed. Can you please send a PR?
Thank you! *José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Thu, Jun 2, 2016 at 11:24 PM, <[email protected]> wrote: > Thank you very much for taking the time to answer my (newbie) question :-) > > Another question about the logger.ex: shouldn't add_backend and > remove_backend(line 420 and 440) call the flush/1 method instead of > GenEvent.which_handlers(:error_logger) > > diff --git a/lib/logger/lib/logger.ex b/lib/logger/lib/logger.ex > index 0ef5ede..4feddb9 100644 > --- a/lib/logger/lib/logger.ex > +++ b/lib/logger/lib/logger.ex > @@ -417,7 +417,7 @@ defmodule Logger do > > """ > def add_backend(backend, opts \\ []) do > - _ = if opts[:flush], do: GenEvent.which_handlers(:error_logger) > + _ = if opts[:flush], do: flush() > case Logger.Watcher.watch(Logger, > Logger.Config.translate_backend(backend), backend) do > {:ok, _} = ok -> > Logger.Config.add_backend(backend) > @@ -437,7 +437,7 @@ defmodule Logger do > the backend is removed > """ > def remove_backend(backend, opts \\ []) do > - _ = if opts[:flush], do: GenEvent.which_handlers(:error_logger) > + _ = if opts[:flush], do: flush() > Logger.Config.remove_backend(backend) > Logger.Watcher.unwatch(Logger, > Logger.Config.translate_backend(backend)) > end > > > According to the docs both Logger and Erlang's error_logger message will > be flushed if opts[:flush]. And if I understand the code correctly only > error_logger messages will be flushed. > > /Johan > > Den torsdag 2 juni 2016 kl. 22:57:03 UTC+2 skrev José Valim: >> >> The "_ =" is just to signal that the function returns something (in this >> case handlers) but we are not interested in the result. It does not change >> the code in any possible way. If the test fails, that's a race condition in >> the suite and should not be related to your code change. >> >> >> >> *José Valim* >> www.plataformatec.com.br >> Skype: jv.ptec >> Founder and Director of R&D >> >> On Thu, Jun 2, 2016 at 10:48 PM, <[email protected]> wrote: >> >>> This could me my bad: the test failure only occurs sometimes. I guess my >>> computer is to slow :-) >>> >>> Den torsdag 2 juni 2016 kl. 22:15:39 UTC+2 skrev [email protected]: >>>> >>>> OK, so I figured out that "_=" actually has effect because if I remove >>>> _= from line 205 in logger.ex the tests fails. >>>> >>>> $ git diff >>>> diff --git a/lib/logger/lib/logger.ex b/lib/logger/lib/logger.ex >>>> index 0ef5ede..644ffcb 100644 >>>> --- a/lib/logger/lib/logger.ex >>>> +++ b/lib/logger/lib/logger.ex >>>> @@ -402,7 +402,7 @@ defmodule Logger do >>>> """ >>>> @spec flush :: :ok >>>> def flush do >>>> - _ = GenEvent.which_handlers(:error_logger) >>>> + GenEvent.which_handlers(:error_logger) >>>> GenEvent.sync_notify(Logger, :flush) >>>> end >>>> >>>> $ make clean test >>>> ...... >>>> >>>> 1) test drop/2 with negative count stream entries (StreamTest) >>>> test/elixir/stream_test.exs:202 >>>> No message matching {:stream, 1} after 100ms. >>>> The process mailbox is empty. >>>> stacktrace: >>>> test/elixir/stream_test.exs:215: (test) >>>> >>>> >>>> Can someone please help me understand? >>>> >>>> >>>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "elixir-lang-talk" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-talk/3c1f5f6b-cfdc-440d-bbe8-a061660c6622%40googlegroups.com >>> <https://groups.google.com/d/msgid/elixir-lang-talk/3c1f5f6b-cfdc-440d-bbe8-a061660c6622%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAGnRm4LsOeGkyRq4bsCtuTFcW5ErHz7_ULgony%2Bsf6O797dnJA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
