From 9cce6a7f7e8441892694e98afc808c6d5e90276c Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Sun, 19 Nov 2023 14:20:33 +0000 Subject: [PATCH 1/5] A few changes. --- log4cl-extras.asd | 3 +-- qlfile.lock | 4 ++-- src/appenders.lisp | 11 ++++++++++- src/changelog.lisp | 13 +++++++++++++ src/core.lisp | 6 ++++++ 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/core.lisp diff --git a/log4cl-extras.asd b/log4cl-extras.asd index c1bb406..373f0d1 100644 --- a/log4cl-extras.asd +++ b/log4cl-extras.asd @@ -11,8 +11,7 @@ ;; additional dependency system :secret-values ;; ;; "log4cl-extras/secrets" - "log4cl-extras/config" - "log4cl-extras/error") + "log4cl-extras/core") :description "A bunch of addons to LOG4CL: JSON appender, context fields, cross-finger appender, etc." :long-description " diff --git a/qlfile.lock b/qlfile.lock index dd61e59..beded05 100644 --- a/qlfile.lock +++ b/qlfile.lock @@ -1,8 +1,8 @@ ("quicklisp" . (:class qlot/source/dist:source-dist :initargs (:distribution "http://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest) - :version "2023-02-15")) + :version "2023-10-21")) ("ultralisp" . (:class qlot/source/dist:source-dist :initargs (:distribution "http://dist.ultralisp.org/" :%version :latest) - :version "20230422190002")) + :version "20231119095000")) diff --git a/src/appenders.lisp b/src/appenders.lisp index ac52414..b95247a 100644 --- a/src/appenders.lisp +++ b/src/appenders.lisp @@ -1,14 +1,21 @@ (defpackage #:log4cl-extras/appenders (:use #:cl) (:import-from #:log4cl) + (:import-from #:global-vars + #:define-global-var) (:export #:stable-daily-file-appender #:stable-this-console-appender #:dont-disable-mixin - #:stable-file-appender)) + #:stable-file-appender + #:*debug-on-error*)) (in-package log4cl-extras/appenders) +(define-global-var *debug-on-error* nil + "When T, then INVOKE-DEBUGGER will be called in case of any error during logging the message.") + + (defclass dont-disable-mixin () ()) @@ -31,4 +38,6 @@ "~@" (type-of condition) condition)) + (when *debug-on-error* + (invoke-debugger condition)) :ignore) diff --git a/src/changelog.lisp b/src/changelog.lisp index feef822..7ba2fdc 100644 --- a/src/changelog.lisp +++ b/src/changelog.lisp @@ -16,7 +16,20 @@ ":JSON" ":PLAIN" "HTTP" + "ASDF" "TRACEBACK-TO-STRING")) + (0.10.0 2023-11-19 + " +## New + +Variable LOG4CL-EXTRAS/APPENDERS:*DEBUG-ON-ERROR* was added and can be used to debug issues happening when handling log messages. +When this option is NIL, appenders defined in log4cl-extras will only output \"Unable to log the message\" message in case of errors +during the message output. + +## Fixes + +* Package log4cl-extras now is created when library is loaded. This should fix a warning from ASDF about missing package. +") (0.9.0 2022-12-30 "Function LOG4CL-EXTRAS/ERROR:PRINT-BACKTRACE now prints conditions with type like: diff --git a/src/core.lisp b/src/core.lisp new file mode 100644 index 0000000..af0f402 --- /dev/null +++ b/src/core.lisp @@ -0,0 +1,6 @@ +(uiop:define-package #:log4cl-extras + (:use #:cl) + (:nicknames #:log4cl-extras/core) + (:import-from #:log4cl-extras/config) + (:import-from #:log4cl-extras/error)) +(in-package #:log4cl-extras) From 541e2ec30040835fa5683b11aa715518fbd8596d Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Sun, 19 Nov 2023 14:23:41 +0000 Subject: [PATCH 2/5] Push checks From 0010c856be90cbe7848d9e80f18cbd0c3bed39e3 Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Sun, 19 Nov 2023 16:15:38 +0000 Subject: [PATCH 3/5] Added documentation section on appenders. --- src/appenders.lisp | 20 ++++++++++++++++++++ src/doc.lisp | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/appenders.lisp b/src/appenders.lisp index b95247a..f890cfd 100644 --- a/src/appenders.lisp +++ b/src/appenders.lisp @@ -3,6 +3,8 @@ (:import-from #:log4cl) (:import-from #:global-vars #:define-global-var) + (:import-from #:40ants-doc + #:defsection) (:export #:stable-daily-file-appender #:stable-this-console-appender @@ -41,3 +43,21 @@ (when *debug-on-error* (invoke-debugger condition)) :ignore) + + +(defsection @appenders (:title "Appenders" + :ignore-words (list "SOME-ERROR")) + "In case of errors, LOG4CL removes appender from the logger. After that log message will be lost. + + I don't like this behaviour and prefer to see such errors in logs and to log other + messages. This library defines a special appender classes which are not removed on errors but + output this message instead: \"Caught SOME-ERROR: Error description - Unable to log the message.\". + + When you use LOG4CL-EXTRAS/CONFIG:SETUP function it automatically uses these appenders. + + To debug logging errors interactively, you can set *DEBUG-ON-ERROR* variable to T." + (stable-daily-file-appender class) + (stable-file-appender class) + (stable-this-console-appender class) + (dont-disable-mixin class) + (*debug-on-error* variable)) diff --git a/src/doc.lisp b/src/doc.lisp index 813c093..282e746 100644 --- a/src/doc.lisp +++ b/src/doc.lisp @@ -19,6 +19,8 @@ #:@changelog) (:import-from #:docs-config #:docs-config) + (:import-from #:log4cl-extras/appenders + #:@appenders) (:export #:@index #:@readme @@ -56,7 +58,8 @@ (@configuration section) (@context section) (@errors section) - (@keeping-secrets section)) + (@keeping-secrets section) + (@appenders section)) (defsection-copy @readme @index) @@ -72,3 +75,4 @@ You can install this library from Quicklisp, but you want to receive updates qui (ql:quickload :log4cl-extras) ``` """) + From a2fe7b21506a686a1009c8b86fc0bdf4b2e5e195 Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Mon, 20 Nov 2023 06:58:13 +0000 Subject: [PATCH 4/5] Turned off cache fro doc CI to check if it will be build correctly without cached state. --- .github/workflows/ci.yml | 6 +++--- .github/workflows/docs.yml | 29 +---------------------------- src/ci.lisp | 2 +- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bce531..c3a7b58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,8 +61,8 @@ "if": "steps.cache.outputs.cache-hit != 'true'" }, { - "name": "Change dist to Ultralisp", - "run": "echo 'dist ultralisp http://dist.ultralisp.org' > qlfile", + "name": "Change dist to Ultralisp if qlfile does not exist", + "run": "if [[ ! -e qlfile ]]; then echo 'dist ultralisp http://dist.ultralisp.org' > qlfile; fi", "shell": "bash" }, { @@ -72,7 +72,7 @@ }, { "name": "Install SBLint wrapper", - "run": "qlot exec ros install 40ants-linter", + "run": "qlot exec ros install 40ants-asdf-system 40ants-linter", "shell": "bash" }, { diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 83f4fdb..261c3c8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -26,39 +26,12 @@ "name": "Checkout Code", "uses": "actions/checkout@v3" }, - { - "name": "Grant All Perms to Make Cache Restoring Possible", - "run": "sudo mkdir -p /usr/local/etc/roswell\n sudo chown \"${USER}\" /usr/local/etc/roswell\n # Here the ros binary will be restored:\n sudo chown \"${USER}\" /usr/local/bin", - "shell": "bash" - }, - { - "name": "Get Current Month", - "id": "current-month", - "run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT", - "shell": "bash" - }, - { - "name": "Cache Roswell Setup", - "id": "cache", - "uses": "actions/cache@v3", - "with": { - "path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot", - "key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-ubuntu-latest-quicklisp-sbcl-bin-${{ hashFiles('qlfile.lock', '*.asd') }}" - } - }, - { - "name": "Restore Path To Cached Files", - "run": "echo $HOME/.roswell/bin >> $GITHUB_PATH\n echo .qlot/bin >> $GITHUB_PATH", - "shell": "bash", - "if": "steps.cache.outputs.cache-hit == 'true'" - }, { "name": "Setup Common Lisp Environment", "uses": "40ants/setup-lisp@v2", "with": { "asdf-system": "log4cl-extras/doc" - }, - "if": "steps.cache.outputs.cache-hit != 'true'" + } }, { "name": "Build Docs", diff --git a/src/ci.lisp b/src/ci.lisp index 6ee4795..ee0a1d5 100644 --- a/src/ci.lisp +++ b/src/ci.lisp @@ -32,5 +32,5 @@ :on-push-to "master" :on-pull-request t :by-cron "0 10 * * 1" - :cache t + ;; :cache t :jobs ((build-docs :asdf-system "log4cl-extras/doc"))) From d3a57cb0597ae62f8c1fb626c8eb2a3f48f328bf Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Tue, 28 Nov 2023 23:01:07 +0000 Subject: [PATCH 5/5] Updated deps. --- qlfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qlfile.lock b/qlfile.lock index beded05..ba26586 100644 --- a/qlfile.lock +++ b/qlfile.lock @@ -5,4 +5,4 @@ ("ultralisp" . (:class qlot/source/dist:source-dist :initargs (:distribution "http://dist.ultralisp.org/" :%version :latest) - :version "20231119095000")) + :version "20231128222503"))