From 5b1c3e6b9ef1f8b002e571cae0a13a4195cbaf58 Mon Sep 17 00:00:00 2001 From: Oleksii Sholik Date: Tue, 3 Dec 2024 14:34:53 +0200 Subject: [PATCH] feat: add ability to disable colored logs; rename logging-related env vars (#2068) Related documentation update - https://github.com/electric-sql/electric/pull/2067. --- .changeset/sweet-timers-add.md | 5 +++++ packages/sync-service/.env.dev | 4 ++-- packages/sync-service/.env.test | 2 +- packages/sync-service/config/runtime.exs | 8 ++++++-- 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .changeset/sweet-timers-add.md diff --git a/.changeset/sweet-timers-add.md b/.changeset/sweet-timers-add.md new file mode 100644 index 0000000000..9e17d83305 --- /dev/null +++ b/.changeset/sweet-timers-add.md @@ -0,0 +1,5 @@ +--- +"@core/sync-service": patch +--- + +Resolve naming confusion between `ELECTRIC_LOG_CHUNK_BYTES_THRESHOLD` and logging-related configuration options. Add `ELECTRIC_` prefix to `LOG_LEVEL` to `LOG_OTP_REPORTS` config options. Introduce a new config option named `ELECTRIC_LOG_COLORS`. diff --git a/packages/sync-service/.env.dev b/packages/sync-service/.env.dev index 346d295c7d..fceb8f73c5 100644 --- a/packages/sync-service/.env.dev +++ b/packages/sync-service/.env.dev @@ -1,9 +1,9 @@ -LOG_LEVEL=debug +ELECTRIC_LOG_LEVEL=debug DATABASE_URL=postgresql://postgres:password@localhost:54321/electric?sslmode=disable ELECTRIC_ENABLE_INTEGRATION_TESTING=true ELECTRIC_CACHE_MAX_AGE=1 ELECTRIC_CACHE_STALE_AGE=3 # using a small chunk size of 10kB for dev to speed up tests -ELECTRIC_LOG_CHUNK_BYTES_THRESHOLD=10000 +ELECTRIC_SHAPE_CHUNK_BYTES_THRESHOLD=10000 # configuring a second database for multi-tenancy integration testing OTHER_DATABASE_URL=postgresql://postgres:password@localhost:54322/electric?sslmode=disable diff --git a/packages/sync-service/.env.test b/packages/sync-service/.env.test index dd48e6bbee..11cd391a92 100644 --- a/packages/sync-service/.env.test +++ b/packages/sync-service/.env.test @@ -1,2 +1,2 @@ -LOG_LEVEL=info +ELECTRIC_LOG_LEVEL=info DATABASE_URL=postgresql://postgres:password@localhost:54321/postgres?sslmode=disable diff --git a/packages/sync-service/config/runtime.exs b/packages/sync-service/config/runtime.exs index db4c0b2c46..7c50efd0f5 100644 --- a/packages/sync-service/config/runtime.exs +++ b/packages/sync-service/config/runtime.exs @@ -8,7 +8,7 @@ if config_env() in [:dev, :test] do end log_level_config = - env!("LOG_LEVEL", :string, "info") + env!("ELECTRIC_LOG_LEVEL", :string, "info") |> Electric.ConfigParser.parse_log_level() case log_level_config do @@ -19,6 +19,10 @@ case log_level_config do raise message end +if !env!("ELECTRIC_LOG_COLORS", :boolean, true) do + config :logger, :default_formatter, colors: [enabled: false] +end + # Enable this to get **very noisy** but useful messages from BEAM about # processes being started, stopped and crashes. # https://www.erlang.org/doc/apps/sasl/error_logging#sasl-reports @@ -140,7 +144,7 @@ persistent_kv = chunk_bytes_threshold = env!( - "ELECTRIC_LOG_CHUNK_BYTES_THRESHOLD", + "ELECTRIC_SHAPE_CHUNK_BYTES_THRESHOLD", :integer, Electric.ShapeCache.LogChunker.default_chunk_size_threshold() )