Skip to content

Commit

Permalink
[RTC-399] Basic toggleable structured logging (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgfn authored Feb 21, 2024
1 parent 9dff586 commit a27e582
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id, :room_id]

config :logger_json, :backend,
metadata: [:request_id, :room_id],
json_encoder: Jason,
formatter: LoggerJSON.Formatters.BasicLogger

config :phoenix, :json_library, Jason
config :phoenix, :logger, false

Expand All @@ -27,7 +32,9 @@ config :logger,
[application: :membrane_rtc_engine, level_lower_than: :warning],
[application: :membrane_rtc_engine_webrtc, level_lower_than: :warning],
[application: :membrane_rtc_engine_hls, level_lower_than: :warning],
[application: :membrane_rtc_engine_rtsp, level_lower_than: :warning]
[application: :membrane_rtc_engine_rtsp, level_lower_than: :warning],
[application: :membrane_rtc_engine_file, level_lower_than: :warning],
[application: :membrane_rtc_engine_sip, level_lower_than: :warning]
]

config :jellyfish,
Expand Down
3 changes: 3 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ alias Jellyfish.ConfigReader
# The block below contains prod specific runtime configuration.
config :ex_dtls, impl: :nif

structured_logging? = ConfigReader.read_boolean("JF_STRUCTURED_LOGGING") || false
config :logger, backends: [if(structured_logging?, do: LoggerJSON, else: :console)]

prod? = config_env() == :prod

ip = ConfigReader.read_ip("JF_IP") || Application.fetch_env!(:jellyfish, :ip)
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ defmodule Jellyfish.MixProject do
{:open_api_spex, "~> 3.16"},
{:ymlr, "~> 3.0"},
{:bunch, "~> 1.6"},
{:logger_json, "~> 5.1"},

# aws deps
{:ex_aws, "~> 2.1"},
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"klotho": {:hex, :klotho, "0.1.2", "3b1f1a569703e0cdce1ba964f41711351a7b06846c38fcbd601faa407e712bf2", [:mix], [], "hexpm", "a6a387982753582e30a5246fe9561721c6b9a4dd27678296cf2cd44faa6f3733"},
"libcluster": {:hex, :libcluster, "3.3.3", "a4f17721a19004cfc4467268e17cff8b1f951befe428975dd4f6f7b84d927fe0", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "7c0a2275a0bb83c07acd17dab3c3bfb4897b145106750eeccc62d302e3bdfee5"},
"logger_json": {:hex, :logger_json, "5.1.3", "fe931b54826e7ba3b1233ede5c13d87cd670a23563f8d146d0ee22985549dbb5", [:mix], [{:ecto, "~> 2.1 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.5.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "ecc67e24f9ccf1688c5e48c3d6b7889a0ab5d398fe32a7fec69c461303a9b89c"},
"membrane_aac_fdk_plugin": {:hex, :membrane_aac_fdk_plugin, "0.18.5", "74a0fd9b121a9f18e038573931fa2952b95a977a4e982a844734129e977e0fb9", [:mix], [{:bunch, "~> 1.4", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.3", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_aac_format, "~> 0.8.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.16.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_precompiled_dependency_provider, "~> 0.1.0", [hex: :membrane_precompiled_dependency_provider, repo: "hexpm", optional: false]}, {:membrane_raw_audio_format, "~> 0.12.0", [hex: :membrane_raw_audio_format, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "560ea01c1fc707770bcdfb30d47be5f77be3e4d86a872bc1e34261a134bf6f98"},
"membrane_aac_format": {:hex, :membrane_aac_format, "0.8.0", "515631eabd6e584e0e9af2cea80471fee6246484dbbefc4726c1d93ece8e0838", [:mix], [{:bimap, "~> 1.1", [hex: :bimap, repo: "hexpm", optional: false]}], "hexpm", "a30176a94491033ed32be45e51d509fc70a5ee6e751f12fd6c0d60bd637013f6"},
"membrane_aac_plugin": {:hex, :membrane_aac_plugin, "0.18.1", "30433bffd4d5d773f79448dd9afd55d77338721688f09a89b20d742a68cc2c3d", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_aac_format, "~> 0.8.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "8fd048c47d5d2949eb557e19f43f62d534d3af5096187f1a1a3a1694d14b772c"},
Expand Down

0 comments on commit a27e582

Please sign in to comment.