clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.55k stars 645 forks source link

Nothing is logged to cider-log buffer #3751

Closed maacl closed 1 month ago

maacl commented 1 month ago

Expected behavior

cider-log buffer receives and displays log messages.

Actual behavior

cider-log buffer remains empty and all messages are logged to the repl.

Steps to reproduce the problem

cider-log-show

Environment & Version information

WSL

CIDER version information

CIDER 1.15.1 (Cogne), nREPL 1.3.0, Clojure 1.12.0, Java 23

Lein / Clojure CLI version

See above.

Emacs version

29.4

Operating system

Ubuntu 22.04.5 LTS under WSL:

WSL version: 2.3.24.0 Kernel version: 5.15.153.1-2 WSLg version: 1.0.65 MSRDC version: 1.2.5620 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26100.1-240331-1435.ge-release Windows version: 10.0.22631.4317

JDK distribution

openjdk version "21.0.2" 2024-01-16 LTS OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode, sharing)

vemv commented 1 month ago

This happened to both of us as we were trying to use the Timbre integration.

The cider-log buffer is empty because JUL is chosen instead of Timbre, because JUL is determined as the sole available option, because Timbre cannot be loaded:

logjam.framework> (require 'logjam.framework.timbre :reload)
Syntax error (ArityException) compiling at (logjam/framework/timbre.clj:82:9).
Wrong number of args (1) passed to: taoensso.timbre/log!

This looks like a breaking change from Timbre's side. Should have a simple fix in Logjam.

bbatsov commented 1 month ago

@r0man Can you take a look at this?

r0man commented 1 month ago

Hi,

I had a quick look, but I'm having a hard time to reproduce this. This is what I did:

  1. Checked out logjam from https://github.com/clojure-emacs/logjam
  2. Make sure cider/cider-nrepl is at version "0.50.2" (the one in the repo is missing a fix from @vemv)
  3. Start a REPL with lein update-in :dependencies conj \[nrepl/nrepl\ \"1.3.0\"\] -- update-in :dependencies conj \[refactor-nrepl/refactor-nrepl\ \"3.10.0\"\] -- update-in :plugins conj \[refactor-nrepl/refactor-nrepl\ \"3.10.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.50.2\"\] -- with-profile +test repl :headless :host localhost
  4. Open logjam.framework.timbre-test
  5. Run M-x cider-log-show
  6. Eval (timbre/infof "foo %s" 42) at line 66

After doing so, I see the log line in the *cider-log* buffer as:

2024-10-28 09:31:18.000 [nREPL-session-b3a1e5bc-fd2d-4d08-97cf-75ef5f18c554] INFO logjam.framework.timbre-test:66:5 - foo 42

I also see it in the REPL as:

2024-10-28T08:31:18.301Z precision INFO [logjam.framework.timbre-test:66] - foo 42

What I see in *cider-log* looks good to me. The line in the REPL I would not have expected, but I guess this is Timbre's default logger. @vemv is this the expected behaviour when you implemented this? I'm not using Timbre and never tried it before with cider-log.

I opened a PR over here that updates some of logjams dependencies: https://github.com/clojure-emacs/logjam/pull/19

But this isn't fixing the issue at hand. It only includes a fix from @vemv in cider-nrepl which I run into while trying this in the logjam repository.

I need more information:

vemv commented 1 month ago

Hey @r0man , thanks for your efforts!

You are right, it works. What I had to do locally in my specific project was:

For a long while I was actually unable to upgrade Timbre/Encore in my work project, for contrived reasons. But now I finally can, and it all works.

I'd just add these some tips to the manual:

You can try those right now, @maacl .

Cheers - V

r0man commented 1 month ago

Thanks @vemv. Maybe @maacl can come up with exact steps to reproduce this (in the logjam repo)?

maacl commented 1 month ago

Hey @r0man , thanks for your efforts!

You are right, it works. What I had to do locally in my specific project was:

For a long while I was actually unable to upgrade Timbre/Encore in my work project, for contrived reasons. But now I finally can, and it all works.

I'd just add these some tips to the manual:

  • Elisp side, one can M-: (cider-sync-request:log-frameworks)

    • if our framework of choice is absent, then things won't work properly and signals some problem
  • Clojure side, one can debug why a specific framework may be absent by running (require 'logjam.framework.timbre :reload)

    • Or any other such namespace listed in logjam.framework/*frameworks*
  • For Timbre specifically, it's often useful to have Timbre + Encore at latest stable.

You can try those right now, @maacl .

Cheers - V

M-: (cider-sync-request:log-frameworks)

gives me:

Debugger entered--Lisp error: (void-function cider-sync-request:log-frameworks)
  (cider-sync-request:log-frameworks)
  eval-expression((cider-sync-request:log-frameworks) nil nil 127)
  funcall-interactively(eval-expression (cider-sync-request:log-frameworks) nil nil 127)
  command-execute(eval-expression)
vemv commented 1 month ago

Try (require 'cider-log) beforehand

maacl commented 1 month ago

This works for me now too. I think it was an timbre/encore version issue. Thanks.

bbatsov commented 1 month ago

I think we should probably add something in the docs, so that people are not surprised by such version combination issues.

vemv commented 1 month ago

I'm generally tight on time any given day so I'd appreciate if someone could add my recap to the manual https://github.com/clojure-emacs/cider/issues/3751#issuecomment-2441509389

r0man commented 1 month ago

I added something here: https://github.com/clojure-emacs/cider/pull/3753 Wdyt? I'm closing this one. I think we are done here.