Skip to content

Commit 396708a

Browse files
committed
Add cider-log-frameworks command
This command renders the available log frameworks in a buffer. It shows the log framework name, the website and javadocs urls and the levels for now. This is mostly to address @vemv's suggestion to ask the user to run `(cider-sync-request:log-frameworks)`. I hooked the command up at the usual places and added it with a small troubleshooting section to the docs. We could get even more sophisticated and show the current appenders and consumers but I need a designer for this. Let's do this at some other point.
1 parent 7b051c4 commit 396708a

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## master (unreleased)
44

55
### Changes
6-
6+
- [#3753](https://github.com/clojure-emacs/cider/pull/3753) Add `cider-log-frameworks` command to show available log frameworks in a buffer.
77
- [#3746](https://github.com/clojure-emacs/cider/issues/3746): Bring back `cider` completion style for activating backend-driven completion.
88

99
### Bugs fixed

cider-log.el

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ Example values: \"Logback\", \"Timbre\"."
4848
:safe #'stringp
4949
:type 'string)
5050

51+
(defcustom cider-log-frameworks-buffer "*cider-log-frameworks*"
52+
"The name of the log frameworks popup buffer."
53+
:group 'cider
54+
:package-version '(cider . "1.16.1")
55+
:safe #'stringp
56+
:type 'string)
57+
58+
(defcustom cider-log-auto-select-frameworks-buffer t
59+
"Whether to auto-select the log frameworks popup buffer."
60+
:group 'cider
61+
:package-version '(cider . "1.16.1")
62+
:safe #'booleanp
63+
:type 'boolean)
64+
5165
(defcustom cider-log-appender-id "cider-log"
5266
"The name of the default log appender."
5367
:group 'cider
@@ -1032,6 +1046,26 @@ the CIDER Inspector and the CIDER stacktrace mode.
10321046

10331047
;; Framework actions
10341048

1049+
(transient-define-suffix cider-log-frameworks ()
1050+
"Show the log frameworks in a buffer."
1051+
:description "Show frameworks in a buffer"
1052+
(interactive)
1053+
(let ((frameworks (cider-sync-request:log-frameworks)))
1054+
(with-current-buffer (cider-popup-buffer cider-log-frameworks-buffer
1055+
cider-log-auto-select-frameworks-buffer)
1056+
(read-only-mode -1)
1057+
(insert (with-temp-buffer
1058+
(insert (propertize (cider-propertize "Cider Log Frameworks" 'ns) 'ns t) "\n\n")
1059+
(dolist (framework frameworks)
1060+
(insert (propertize (cider-propertize (cider-log-framework-name framework) 'ns) 'ns t) "\n\n")
1061+
(insert (format " Website ......... %s\n" (cider-log-framework-website-url framework)))
1062+
(insert (format " Javadocs ........ %s\n" (cider-log-framework-javadoc-url framework)))
1063+
(insert (format " Levels .......... %s\n" (string-join (cider-log-framework-level-names framework) ", ")))
1064+
(newline))
1065+
(buffer-string)))
1066+
(read-only-mode 1)
1067+
(goto-char (point-min)))))
1068+
10351069
(transient-define-suffix cider-log-browse-javadocs (framework)
10361070
"Browse the Javadoc of the log FRAMEWORK."
10371071
:description "Browse Java documentation"
@@ -1220,6 +1254,7 @@ the CIDER Inspector and the CIDER stacktrace mode.
12201254
(transient-define-prefix cider-log-framework (framework)
12211255
"Show the Cider log framework menu."
12221256
[["Cider Log Framework\n\nActions:"
1257+
("a" cider-log-frameworks)
12231258
("b" cider-log-set-buffer)
12241259
("j" cider-log-browse-javadocs)
12251260
("s" cider-log-set-framework)
@@ -1441,6 +1476,8 @@ based on `transient-mode'."
14411476
(transient-define-prefix cider-log (framework appender)
14421477
"Show the Cider log menu."
14431478
[["Framework Actions"
1479+
("fa" cider-log-frameworks
1480+
:description "Show frameworks in a buffer.")
14441481
("fs" cider-log-set-framework)
14451482
("fb" cider-log-set-buffer)
14461483
("fj" cider-log-browse-javadocs)

doc/modules/ROOT/pages/debugging/logging.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Its usage is mostly self-describing, since each command has its keybinding attac
4949

5050
To use CIDER Log Mode, there two main ways to get started:
5151

52+
* `M-x cider-log-frameworks`, to see the available logging frameworks. If your logging framework is supported but not shown, see the troubleshooting section.
5253
* `M-x cider-log-event`, which uses transient-mode and will not immediately show the logs (you should use transient-mode to show the `+*cider-log*+` buffer)
5354
* `M-x cider-log-show` is a newer function that intends to be an "all-in-one" command, intended for a streamlined experience, which can be useful to get started, or for casual usage.
5455
** It doesn't use transient-mode - it aims to do everything in one step
@@ -178,6 +179,10 @@ or Clojure CLI aliases.
178179
|===
179180
| Command | Keyboard shortcut | Description
180181

182+
| `cider-log-frameworks`
183+
| kbd:[C-c M-l f a]
184+
| Show all available log frameworks in a buffer.
185+
181186
| `cider-log-set-framework`
182187
| kbd:[C-c M-l f s]
183188
| Select the log framework to use.
@@ -351,3 +356,9 @@ using logical AND condition. The following filters are available:
351356
| kbd:[-t]
352357
| Only include log events that were emitted by a thread in the list of `threads`.
353358
|===
359+
360+
== Troubleshooting
361+
362+
- Make sure the logging library is actually supported by CIDER Log Mode and that it is on your classpath.
363+
- Try requiring the https://github.com/clojure-emacs/logjam/tree/master/src/logjam/framework[Logjam] namespace of the logging libre, e.g. `(require 'logjam.framework.<jul|logback|timbre|> :reload)` and make sure it can be loaded without errors.
364+
- Timbre and Encore often have to be upgraded in concert, they use "break versioning". It's often useful to have Timbre + Encore at the latest stable version.

0 commit comments

Comments
 (0)