mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-12-29 19:20:46 +08:00
Add env var for debug logs (#2292)
This commit is contained in:
parent
93637b60f0
commit
d2e875a94f
3 changed files with 20 additions and 0 deletions
|
@ -224,6 +224,9 @@ The following environment variables can be used to configure Livebook on boot:
|
|||
configuration. Defaults to "livebook" under the default user data
|
||||
directory.
|
||||
|
||||
* LIVEBOOK_DEBUG - enables verbose logging, when set to "true". Disabled
|
||||
by default.
|
||||
|
||||
* LIVEBOOK_DEFAULT_RUNTIME - sets the runtime type that is used by default
|
||||
when none is started explicitly for the given notebook. Must be either
|
||||
"standalone" (Elixir standalone), "attached:NODE:COOKIE" (Attached node)
|
||||
|
|
|
@ -91,6 +91,10 @@ defmodule Livebook do
|
|||
Livebook.Config.secret!("LIVEBOOK_SECRET_KEY_BASE") ||
|
||||
Base.encode64(:crypto.strong_rand_bytes(48))
|
||||
|
||||
if Livebook.Config.debug!("LIVEBOOK_DEBUG") do
|
||||
config :logger, level: :debug
|
||||
end
|
||||
|
||||
if port = Livebook.Config.port!("LIVEBOOK_PORT") do
|
||||
config :livebook, LivebookWeb.Endpoint, http: [port: port]
|
||||
end
|
||||
|
|
|
@ -420,6 +420,19 @@ defmodule Livebook.Config do
|
|||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Parses and validates debug mode from env.
|
||||
"""
|
||||
def debug!(env) do
|
||||
if debug = System.get_env(env) do
|
||||
cond do
|
||||
debug in ["1", "true"] -> true
|
||||
debug in ["0", "false"] -> false
|
||||
true -> abort!("expected #{env} to be a boolean, got: #{inspect(debug)}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Parses and validates the port from env.
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue