From d463814da72f28b3323a520314fc52f195ed40ab Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 15 Oct 2020 15:57:30 +0300 Subject: [PATCH] Logger (#367) * Fix error loading sessions after a restart * Add logflare logger --- config/releases.exs | 19 +++++++++++++++++-- mix.exs | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/config/releases.exs b/config/releases.exs index eef6ea2281..0853a69d5c 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -44,7 +44,9 @@ geolite2_country_db = System.get_env("GEOLITE2_COUNTRY_DB") disable_auth = String.to_existing_atom(System.get_env("DISABLE_AUTH", "false")) hcaptcha_sitekey = System.get_env("HCAPTCHA_SITEKEY") hcaptcha_secret = System.get_env("HCAPTCHA_SECRET") - +logflare_api_key = System.get_env("LOGFLARE_API_KEY") +logflare_source_id = System.get_env("LOGFLARE_SOURCE_ID") +log_level = String.to_existing_atom(System.get_env("LOG_LEVEL", "warn")) config :plausible, admin_user: admin_user, @@ -192,4 +194,17 @@ if geolite2_country_db do ] end -config :logger, level: :warn +logger_backends = case logflare_api_key do + api_key when is_binary(api_key) -> [LogflareLogger.HttpBackend] + _ -> [:console] +end + +config :logger, + level: log_level, + backends: logger_backends + +if logflare_api_key do + config :logflare_logger_backend, + api_key: logflare_api_key, + source_id: logflare_source_id +end diff --git a/mix.exs b/mix.exs index f0aa03bd4a..8fcfe4385c 100644 --- a/mix.exs +++ b/mix.exs @@ -90,7 +90,8 @@ defmodule Plausible.MixProject do {:sshex, "2.2.1"}, {:geolix, "~> 1.0"}, {:clickhouse_ecto, git: "https://github.com/plausible/clickhouse_ecto.git"}, - {:geolix_adapter_mmdb2, "~> 0.5.0"} + {:geolix_adapter_mmdb2, "~> 0.5.0"}, + {:logflare_logger_backend, "~> 0.7.6"}, ] end