mirror of
https://github.com/penpot/penpot.git
synced 2026-10-03 09:16:15 +00:00
* 🐛 Stop browser logging from crashing on empty levels Stop level->int crashes from taking down the dashboard when a nil or unknown level reaches the browser logger. Invalid levels now warn and are ignored in enabled?, setup! and the console handler, which renders unknown records with a neutral fallback. Alias the schema-legal :fatal level to :error in the browser mappings and validate the JS-exported debug.set_logging, which previously threw on missing arguments and wrote unreachable keyword keys into the loggers map. Closes #11690 AI-assisted-by: muse-spark-1.3-contributor * 🐛 Guard logger args and strengthen logging tests Close the residual throw paths next to the empty-level crash: guard non-string loggers in enabled? and setup!, coerce set_logging arguments safely, and validate logger keys. Strengthen the regression tests so the fatal alias cannot regress silently: enabled-logger filtering, JVM fatal and bogus cases, setup! skip proof, and invalid-logger cases. Related to #11690 AI-assisted-by: muse-spark-1.3-contributor * 🐛 Address low findings from logging review Validate the logger before the level in console-log-handler, share a public valid-logger? predicate with debug/set-logging, and keep warn formatting consistent across boundaries. Document the fail-soft-FE/strict-BE split on enabled? and the valid-level? contract on set-level!. Cover safe fallbacks, bad logger keys, handler logger skips, and loggers-map isolation in common tests, and add a frontend test for debug/set-logging. Related to #11690 AI-assisted-by: muse-spark-1.3-contributor
29 lines
1.1 KiB
Clojure
29 lines
1.1 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS INC Sucursal en España SL
|
|
|
|
(ns frontend-tests.debug-logging-test
|
|
(:require
|
|
[app.common.logging :as l]
|
|
[cljs.test :as t :include-macros true]
|
|
[debug :as dbg]))
|
|
|
|
(t/deftest set-logging-test
|
|
(t/testing "invalid inputs warn and do not throw"
|
|
(t/is (nil? (dbg/set-logging nil)))
|
|
(t/is (nil? (dbg/set-logging "bogus")))
|
|
(t/is (nil? (dbg/set-logging 123)))
|
|
(t/is (nil? (dbg/set-logging nil nil)))
|
|
(t/is (nil? (dbg/set-logging "app" "bogus")))
|
|
(t/is (nil? (dbg/set-logging "app" nil)))
|
|
(t/is (nil? (dbg/set-logging "" "debug"))))
|
|
(t/testing "valid inputs install a string logger key"
|
|
(dbg/set-logging "app" "debug")
|
|
(t/is (true? (l/enabled? "app" :debug)))
|
|
(dbg/set-logging "app" "error")
|
|
(t/is (true? (l/enabled? "app" :error)))
|
|
(t/is (false? (l/enabled? "app" :debug)))
|
|
(.delete l/loggers "app")))
|