doublep / logview

Emacs mode for viewing log files
GNU General Public License v3.0
154 stars 18 forks source link

logview-difference-to-current-entry seems broken #55

Closed rnikander closed 5 months ago

rnikander commented 5 months ago

I recently installed logview and I'm experimenting with different commands. If I type z a, I get an error.

Example log:

2024-04-19 15:00:23.529003 [31652] DEBUG vh.App - get_supported_instance_extensions() - start
2024-04-19 15:00:23.572853 [31652] DEBUG vh.App - found instance extensions: 12
2024-04-19 15:00:23.576014 [31652] DEBUG vh.App -    0. VK_KHR_device_group_creation

z a on that first line leads to:

Debugger entered--Lisp error: (void-function nil)
  nil("2024-04-19 15:00:23.529003")
  #f(compiled-function () #<bytecode -0x117102b1bd31b9b2>)()
  #f(compiled-function () #<bytecode -0x84ee57d83187807>)()
  internal--without-restriction(#f(compiled-function () #<bytecode -0x84ee57d83187807>) long-line-optimizations-in-command-hooks)
  #f(compiled-function () #<bytecode -0x1de6b678879aefed>)()
  internal--without-restriction(#f(compiled-function () #<bytecode -0x1de6b678879aefed>) long-line-optimizations-in-fontification-functions)
  logview--do-temporarily-widening(#f(compiled-function () #<bytecode -0x117102b1bd31b9b2>))
  logview-difference-to-current-entry()
  funcall-interactively(logview-difference-to-current-entry)
  command-execute(logview-difference-to-current-entry)
doublep commented 5 months ago

Seems to work fine for me, tested with your log example.

If you evaluate (M-:) expression (not (null logview--submode-timestamp-parser)) in the log buffer, what does it say?

What are the version of Logview and library datetime? What is your OS? Can you restart Emacs and try again (there could be some artifacts in case you upgraded the packages)?

rnikander commented 5 months ago

If you evaluate (M-:) expression (not (null logview--submode-timestamp-parser)) in the log buffer, what does it say?

It says nil.

Other commands are working and the modeline says (Logview/SLF4J ivy).

What are the version of Logview and library datetime? What is your OS? Can you restart Emacs and try again (there could be some artifacts in case you upgraded the packages)?

I restarted Emacs and it's still doing it, but I bet I messed something up with install. I had problems where the install from MELPA was failing and I downloaded some stuff manually.

logview.el says: ;; Version: 0.17.4snapshot datetime.el says: ;; Version: 0.10.1snapshot

My OS is Windows 11 Home.

doublep commented 5 months ago

Well, I then suggest you try to reinstall the packages, just in case.

But if that doesn't help:

rnikander commented 5 months ago

Deleted the packages logview and datetime. Restarted Emacs. Installed logview using the package manager (which also installed datetime). Opened my log file. Tried z a, got same error.

By the way, is a log file supposed to automatically go into read-only mode? When I open my main.log file, it seems to be recognized by logview but I need to run read-only-mode myself.

Anyway, here I tried to evaluate the forms you mention, using M-: in the log buffer. The last two trigger errors.

logview--submode-features => (name level thread timestamp) logview--timestamp-difference-format-string => nil


(datetime--determine-system-timezone) =>
Debugger entered--Lisp error: (error "Failed to determine system timezone (found raw val...")
  error("Failed to determine system timezone%s; consider cu..." " (found raw value: ‘Central Standard Time (Mexico)...")
  datetime--determine-system-timezone()
  eval-expression((datetime--determine-system-timezone) nil nil 127)
  funcall-interactively(eval-expression (datetime--determine-system-timezone) nil nil 127)
  command-execute(eval-expression)

(not (null (datetime-parser-to-float 'java "yyyy-MM-dd" :timezone 'system))) =>
Debugger entered--Lisp error: (error "Failed to determine system timezone (found raw val...")
  error("Failed to determine system timezone%s; consider cu..." " (found raw value: ‘Central Standard Time (Mexico)...")
  datetime--determine-system-timezone()
  datetime--get-timezone((:timezone system))
  datetime-parser-to-float(java "yyyy-MM-dd" :timezone system)
  (null (datetime-parser-to-float 'java "yyyy-MM-dd" :timezone 'system))
  (not (null (datetime-parser-to-float 'java "yyyy-MM-dd" :timezone 'system)))
  eval-expression((not (null (datetime-parser-to-float 'java "yyyy-MM-dd" :timezone 'system))) nil nil 127)
  funcall-interactively(eval-expression (not (null (datetime-parser-to-float 'java "yyyy-MM-dd" :timezone 'system))) nil nil 127)
  command-execute(eval-expression)
doublep commented 5 months ago

By the way, is a log file supposed to automatically go into read-only mode?

Yes.

Reproduced this locally now by making datetime--determine-system-timezone signal an error.

Do you get warnings "⛔ Warning (emacs): Failed to determine system timezone...; consider customizing ‘datetime-timezone’ variable" somewhere in Emacs?

What is the value of (current-time-zone)?

As a workaround you can do (setf datetime-timezone 'Mexico/General) or whatever is appropriate for you (see documentation of the variable). However, I'll try to improve situation here.

rnikander commented 5 months ago

I looked in *Messages* and I don't see that warning. I customized that variable (datetime-timezone) to have the value America/Mexico_City and now the z a command works, and the file opens in a read-only buffer. Nice!

The call to (current-time-zone) returns: (-21600 "Central Standard Time (Mexico)")

Thanks for creating this. I've been working on a C++ code base, and all the logging to console had gotten out of control. Now I log to a file and use this package to view the file - it's a big improvement.

doublep commented 5 months ago

I looked in Messages and I don't see that warning.

Here (Emacs 29.3 on Linux) the warnings don't go to buffer *Messages*, but to their own buffer *Warnings*. This buffer also automatically pops up on the first (or maybe any) warning. But I have no idea how it should work in your case, this is not part of Logview, it just uses the provided warning system.

I will certainly improve Logview to cope with such situations better and will also try to have datetime's timezone autodetermining handle this ("Central Standard Time (Mexico)"). On Linux it's easy because timezone names are exactly how the library has them in its database, but on Windows the same timezones are named differently...

doublep commented 5 months ago

Logview improvements have been released in 0.17.4.