Skip to content

Commit 23657b1

Browse files
NSHkrNSHkr
authored andcommitted
log cleanup
1 parent 00077f4 commit 23657b1

File tree

4 files changed

+14
-30
lines changed

4 files changed

+14
-30
lines changed

config/test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Config
33
# Test environment configuration
44
config :elixir_scope,
55
test_mode: true, # Enable test mode for test supervisor
6-
debug_registry: true,
6+
debug_registry: false,
77
ecto_repos: [],
88
ai: [
99
provider: :mock,

lib/elixir_scope/foundation/graceful_degradation.ex

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,17 @@ defmodule ElixirScope.Foundation.Config.GracefulDegradation do
3333
"""
3434
def cleanup_fallback_system do
3535
try do
36-
:ets.delete(@fallback_table)
37-
38-
# Only log if not in test mode or if debug is enabled
39-
test_mode = Application.get_env(:elixir_scope, :test_mode, false)
40-
debug_enabled = Application.get_env(:elixir_scope, :debug_registry, false)
36+
case :ets.info(@fallback_table) do
37+
:undefined ->
38+
:ok
4139

42-
if not test_mode or debug_enabled do
43-
Logger.debug("Fallback system cleaned up")
40+
_ ->
41+
:ets.delete(@fallback_table)
42+
:ok
4443
end
45-
46-
:ok
47-
catch
48-
:error, :badarg ->
49-
# Only log if not in test mode or if debug is enabled
50-
test_mode = Application.get_env(:elixir_scope, :test_mode, false)
51-
debug_enabled = Application.get_env(:elixir_scope, :debug_registry, false)
52-
53-
if not test_mode or debug_enabled do
54-
Logger.debug("Fallback table already cleaned up")
55-
end
56-
44+
rescue
45+
ArgumentError ->
46+
# Table doesn't exist or already deleted
5747
:ok
5848
end
5949
end

lib/elixir_scope/foundation/process_registry.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ defmodule ElixirScope.Foundation.ProcessRegistry do
503503
# Log cleanup summary
504504
require Logger
505505

506-
# Only log if there were actually services to clean up or if not in test mode
507-
if cleanup_count > 0 or not Application.get_env(:elixir_scope, :test_mode, false) do
506+
# Only log if there were actually services to clean up
507+
if cleanup_count > 0 do
508508
Logger.debug("Cleaned up #{cleanup_count} services from test namespace #{inspect(test_ref)}")
509509
end
510510

lib/elixir_scope/foundation/service_registry.ex

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,8 @@ defmodule ElixirScope.Foundation.ServiceRegistry do
349349
healthy_services: non_neg_integer()
350350
}
351351
def get_service_info(namespace) do
352-
# Only log debug info if not in test mode or if debug_registry is enabled
353-
if not Application.get_env(:elixir_scope, :test_mode, false) or
354-
Application.get_env(:elixir_scope, :debug_registry, false) do
352+
# Only log debug info if debug_registry is explicitly enabled
353+
if Application.get_env(:elixir_scope, :debug_registry, false) do
355354
Logger.debug("Getting service info for namespace #{inspect(namespace)}")
356355
end
357356

@@ -413,11 +412,6 @@ defmodule ElixirScope.Foundation.ServiceRegistry do
413412
unless test_mode do
414413
Logger.info("Cleanup completed for test namespace #{inspect(namespace)}")
415414
end
416-
else
417-
# Only log in debug mode or if not in test mode
418-
if not test_mode or Application.get_env(:elixir_scope, :debug_registry, false) do
419-
Logger.debug("No services to cleanup in test namespace #{inspect(namespace)}")
420-
end
421415
end
422416

423417
:ok

0 commit comments

Comments
 (0)