mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-01 12:41:43 +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
|
configuration. Defaults to "livebook" under the default user data
|
||||||
directory.
|
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
|
* LIVEBOOK_DEFAULT_RUNTIME - sets the runtime type that is used by default
|
||||||
when none is started explicitly for the given notebook. Must be either
|
when none is started explicitly for the given notebook. Must be either
|
||||||
"standalone" (Elixir standalone), "attached:NODE:COOKIE" (Attached node)
|
"standalone" (Elixir standalone), "attached:NODE:COOKIE" (Attached node)
|
||||||
|
|
|
@ -91,6 +91,10 @@ defmodule Livebook do
|
||||||
Livebook.Config.secret!("LIVEBOOK_SECRET_KEY_BASE") ||
|
Livebook.Config.secret!("LIVEBOOK_SECRET_KEY_BASE") ||
|
||||||
Base.encode64(:crypto.strong_rand_bytes(48))
|
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
|
if port = Livebook.Config.port!("LIVEBOOK_PORT") do
|
||||||
config :livebook, LivebookWeb.Endpoint, http: [port: port]
|
config :livebook, LivebookWeb.Endpoint, http: [port: port]
|
||||||
end
|
end
|
||||||
|
|
|
@ -420,6 +420,19 @@ defmodule Livebook.Config do
|
||||||
end
|
end
|
||||||
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 """
|
@doc """
|
||||||
Parses and validates the port from env.
|
Parses and validates the port from env.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue