Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

* put the new logging stuff behind the sauron-log-events variable; ad…

…d documentation
  • Loading branch information...
commit c7aae29c21cfd8ec572e3e77f4d3dfdb7d7556e5 1 parent 7c461e6
@djcb authored
Showing with 30 additions and 9 deletions.
  1. +9 −1
  2. +21 −8 sauron.el
@@ -206,6 +206,14 @@
+*** Seeing /all/ events
+ Sometimes, you may want to see /all/ events instead of filtering them, for
+ example for debugging purposes. For this, there is the variable
+ =sauron-log-events=. If you set it to =t=, /all/ events will be shown in a
+ buffer names =*Sauron Log*=. This buffer shows up to
+ =sauron-log-buffer-max-lines= (default: 1000) lines of the last events.
** connecting to alert.el
John Wiegley's [[][alert.el]] has a bit of overlap with sauron; however, I've added
@@ -301,7 +309,7 @@
You also need to enable the web client support in Transmission - it's in the
'Web' tab of the preferences dialog.
Note, if you start transmission before you start your session, see `Using D-Bus
outside your session'.
29 sauron.el
@@ -89,6 +89,10 @@ nick. Must be < 65536")
"Maximum length of messages in the log (longer messages will be
truncated. If set to nil, there is no maximum.")
+(defvar sauron-log-events nil
+ "Whether to show write all Sauron events (even the filtered ones)
+to the sauron log buffer.")
(defvar sauron-log-buffer-max-lines 1000
"Maximum number of messages to store in the sauron log buffer.
Messages are removed from the buffer when the total number
@@ -206,9 +210,9 @@ e.g. when using ERC")
"*internal* Name of the sauron buffer.")
(defvar sr-log-buffer nil
- "*internal* The sauron log buffer")
+ "*internal* The sauron log buffer.")
-(defconst sr-log-buffer-name " *Sauron Log*"
+(defconst sr-log-buffer-name "*Sauron Log*"
"*internal* Name of the sauron log buffer.")
tkf added a note

Well, the leading space was intended one. I think many packages use it for buffers you want to hide "deeply". For example, anything-filelist+ (a command in anything.el to show buffers and files) does not show the buffer starting with space. But I don't have strong opinion for this; maybe you should not hide this buffer so deeply. I just wanted to differentiate it from the *Sauron* buffer.

@djcb Owner
djcb added a note
tkf added a note

OK. Thanks for the nice package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
(defvar sr-nick-event-hash nil
@@ -382,6 +386,15 @@ For debugging purposes."
(goto-char (point-max))
(recenter -1))))
+(defun sr-add-to-log (line)
+ "Add LINE to the Sauron log buffer."
+ (unless (buffer-live-p sr-log-buffer)
+ (setq sr-log-buffer (sr-create-buffer-maybe sr-log-buffer-name)))
+ (with-current-buffer sr-log-buffer
+ (goto-char (point-max))
+ (insert line)
+ (sr-clear-log-buffer-maybe)))
;; the main work horse function
(defun sauron-add-event (origin prio msg &optional func props)
@@ -423,11 +436,10 @@ PROPS an origin-specific property list that will be passed to the hook funcs."
(line (concat (propertize line 'callback func) "\n"))
(inhibit-read-only t))
- (with-current-buffer
- (setq sr-log-buffer (sr-create-buffer-maybe sr-log-buffer-name))
- (goto-char (point-max))
- (insert line))
- (sr-clear-log-buffer-maybe)
+ ;; when logging is enabled, write the line to the sauron log as well
+ (when sauron-log-events (sr-add-to-log line))
(when (and (>= prio sauron-min-priority)
(null (sr-ignore-errors-maybe
;; ignore errors unless we're debugging
@@ -579,11 +591,12 @@ sauron buffer."
(defun sr-clear-log-buffer-maybe ()
+ "Clear the sauon log "
(when sr-log-buffer
(with-current-buffer sr-log-buffer
(let ((lines (count-lines (point-min) (point-max)))
- (inhibit-read-only t))
+ (inhibit-read-only t))
(when (> lines sauron-log-buffer-max-lines)
(forward-line (- sauron-log-buffer-max-lines lines))
(delete-region (point-min) (point))))))))
Please sign in to comment.
Something went wrong with that request. Please try again.