mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-09 06:24:29 +08:00
Ignore io response messages when logging (#1997)
This commit is contained in:
parent
efb28fbdf0
commit
d4e950bd05
4 changed files with 40 additions and 1 deletions
|
@ -39,6 +39,7 @@ defmodule Livebook.Runtime.ErlDist do
|
|||
Livebook.Runtime.ErlDist.IOForwardGL,
|
||||
Livebook.Runtime.ErlDist.LoggerGLBackend,
|
||||
Livebook.Runtime.ErlDist.LoggerGLHandler,
|
||||
Livebook.Runtime.ErlDist.Sink,
|
||||
Livebook.Runtime.ErlDist.SmartCellGL
|
||||
]
|
||||
end
|
||||
|
|
|
@ -13,7 +13,8 @@ defmodule Livebook.Runtime.ErlDist.LoggerGLHandler do
|
|||
end
|
||||
|
||||
def async_io(device, output) when is_pid(device) do
|
||||
send(device, {:io_request, self(), make_ref(), {:put_chars, :unicode, output}})
|
||||
reply_to = Livebook.Runtime.ErlDist.Sink.pid()
|
||||
send(device, {:io_request, reply_to, make_ref(), {:put_chars, :unicode, output}})
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -98,6 +98,8 @@ defmodule Livebook.Runtime.ErlDist.NodeManager do
|
|||
|
||||
# TODO: remove logger backend once we require Elixir v1.15
|
||||
if Code.ensure_loaded?(Logger) and function_exported?(Logger, :add_handlers, 1) do
|
||||
{:ok, _pid} = Livebook.Runtime.ErlDist.Sink.start_link()
|
||||
|
||||
:logger.add_handler(:livebook_gl_handler, Livebook.Runtime.ErlDist.LoggerGLHandler, %{
|
||||
formatter: Logger.Formatter.new(),
|
||||
filters: [
|
||||
|
|
35
lib/livebook/runtime/erl_dist/sink.ex
Normal file
35
lib/livebook/runtime/erl_dist/sink.ex
Normal file
|
@ -0,0 +1,35 @@
|
|||
defmodule Livebook.Runtime.ErlDist.Sink do
|
||||
@moduledoc false
|
||||
|
||||
# An idle process that ignores all incoming messages.
|
||||
|
||||
use GenServer
|
||||
|
||||
@name __MODULE__
|
||||
|
||||
@doc """
|
||||
Starts the process.
|
||||
"""
|
||||
@spec start_link() :: GenServer.on_start()
|
||||
def start_link() do
|
||||
GenServer.start_link(__MODULE__, {}, name: @name)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns pid of the global sink process.
|
||||
"""
|
||||
@spec pid() :: pid()
|
||||
def pid() do
|
||||
Process.whereis(@name)
|
||||
end
|
||||
|
||||
@impl true
|
||||
def init({}) do
|
||||
{:ok, {}}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info(_message, state) do
|
||||
{:noreply, state}
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue