Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to disable colored logs; rename logging-related env vars #2068

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sweet-timers-add.md
Original file line number Diff line number Diff line change
@@ -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`.
4 changes: 2 additions & 2 deletions packages/sync-service/.env.dev
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion packages/sync-service/.env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LOG_LEVEL=info
ELECTRIC_LOG_LEVEL=info
DATABASE_URL=postgresql://postgres:password@localhost:54321/postgres?sslmode=disable
8 changes: 6 additions & 2 deletions packages/sync-service/config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
)
Expand Down