From 9ff7fcb02dd181c3cfd9f096a62fd091d2edffd0 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Sat, 6 Jun 2026 17:54:17 +0200 Subject: [PATCH] Don't crash if ct_log/2 is called when app not running --- src/gm_ctflow.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gm_ctflow.erl b/src/gm_ctflow.erl index d1fdf0d..f06209b 100644 --- a/src/gm_ctflow.erl +++ b/src/gm_ctflow.erl @@ -61,13 +61,19 @@ ct_log(Flow, Fmt, Args) -> TS = timestamp(), case Flow of undefined -> - save_log(undefined, TS, Fmt, Args), + maybe_save_log_no_flow(TS, Fmt, Args), ct:log(Fmt, Args); Flow -> save_log(Flow, TS, Fmt, Args), ct:log("~p[~w]: " ++ Fmt, [Flow, self()|Args]) end. - + +maybe_save_log_no_flow(TS, Fmt, Args) -> + try save_log(undefined, TS, Fmt, Args) + catch + error:_ -> + ok + end. save_log(Flow, TS, Fmt, Args) -> gm_ctflow_log:log(Flow, TS, Fmt, Args).