Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax sugar for logging macros to drop innermost level of auto-naming #20

Open
7max opened this issue Sep 13, 2013 · 0 comments
Open
Labels

Comments

@7max
Copy link
Owner

7max commented Sep 13, 2013

There is an often used pattern is Lisp for writing wrappers like this:

(defun call-with-wrapping (thunk)
  (unwind-protect 
      (progn
         (log:trace "Wrapping is on")
         (funcall thunk))
    (log:trace "Wrapping is off")

(defmacro with-wrapping (&body body)
  `(call-with-wrapping (lambda () ,@body))

(defun foobar ()
  (call-with-wrapping ...))

Currently above results in log category auto-naming making the log category
of package.foobar.call-with-wrapping.lambda, which is too much information we don't want.

Its possible to fix the above pattern, by adding a logger object argument to call-with-wrapping, and passing the logger object to macro like this.

(defun call-with-wrapping (logger thunk)
  (unwind-protect 
      (progn
         (log:trace :logger logger "Wrapping is on")
         (funcall thunk))
    (log:trace :logger logger  "Wrapping is off")

(defmacro with-wrapping (&body body)
  `(call-with-wrapping (log:category) (lambda () ,@body))

(defun foobar ()
  (call-with-wrapping ...))

But it would be nice if above can be done without such workaround, by adding some syntax sugar to logging macros, that indicate that auto category naming should drop a level, something like (log:trace /// ....) or (log:trace ***) to indicate that naming should drop 3 levels

svetlyak40wt pushed a commit to 40ants/log4cl that referenced this issue Dec 2, 2017
watcher: wrap release-lock in ignore-errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant