From: Frank Goenninger DG1SBG
Subject: Why oh why does this not work ? (member ...)
Date: 
Message-ID: <lzvea7brwx.fsf@de.goenninger.net>
Yeah, I know, I should know why this doesn't work, but I seem to be
mind-blocked ...

Here we go:

;; Remark: function up$ returns a string with all characters being
   UPPER CASE letters 

(defparameter *debug-modules* nil 
  "Holds the module names for which debugging is enabled globally.")

(defparameter *debug-functions* nil 
  "Holds the function names for which debugging is enabled.")

(defparameter *module* nil 
  "Holds the currently active module name.")

(defmacro in-module (module-name)
  (eval-when (:load-toplevel :compile-toplevel :execute)
    `(setf net.goenninger.app.debug:*module* (up$ ,module-name))))

(defmacro logmsg (msg-class method method-desc msg &rest msg-args)
  `(logmsg-fn ,msg-class
              (find-package-defining-symbol ,method) ;; returns a string
              ,method
              ,method-desc
              ,msg
              ,@msg-args))

(defun logmsg-fn (msg-class package method method-desc msg &rest msg-args)
  (format t "~a ~a" (type-of (up$ (symbol-name method))) package)
  (when (and (member (up$ (symbol-name method)) *debug-functions*)
             (member *module* *debug-modules*))
    (format *debug-io* "~&~%-------------------------------------------------------------------------------")
    (format *debug-io* "~&*** ~A [ PKG ~A, FN ~S ( ~A ) ]~&"
	          msg-class package method method-desc)
    (format *debug-io* "*** ")
    (apply 'format *debug-io* msg msg-args)
    (format *debug-io* "~%")
    (force-output *debug-io*)))

(defmethod enable-debugging ((key (eql :module)) module-name)
  (pushnew (up$ module-name) *debug-modules* :test #'string=))

(defmethod enable-debugging ((key (eql :function)) function-name)
  (pushnew (up$ (symbol-name function-name)) *debug-functions* :test #'string=))

(defmethod disable-debugging ((key (eql :module)) module-name)
  (setf *debug-modules* (remove (up$ module-name) *debug-modules*)))

(defmethod disable-debugging ((key (eql :function)) function-name)
  (setf *debug-modules* (remove (up$ (symbol-name function-name)) *debug-functions*)))

Session transcript:

CL-USER> (reset-debugging-settings)
NIL

CL-USER> (enable-debugging :module "FRGO")
("FRGO")

CL-USER> (enable-debugging :function 'test-fn)
("TEST-FN")

CL-USER> (in-module "FRGO")
"FRGO"

CL-USER> (defun test-fn ()
           (logmsg :INFO 'test-fn "-" "Yeah.")
           (format t "~%... test-fn called ...~%"))
TEST-FN

CL-USER> (test-fn)
... test-fn called ...
NIL

CL-USER> 

Clearly, the (when ...) statement does not fire - but
whatever thing I tried ... I can't seem to get the (member ...) tests
to return t...

Being desperate ...

Thx!!!

Frank

-- 

  Frank Goenninger

  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."

From: Pillsy
Subject: Re: Why oh why does this not work ? (member ...)
Date: 
Message-ID: <1190150402.750479.117630@y42g2000hsy.googlegroups.com>
On Sep 18, 5:11 pm, Frank Goenninger DG1SBG <·············@nomail.org>
wrote:
> Yeah, I know, I should know why this doesn't work, but I seem to be
> mind-blocked ...
[...]
> Clearly, the (when ...) statement does not fire - but
> whatever thing I tried ... I can't seem to get the (member ...) tests
> to return t...

I'm going to take a bit of a stab in the dark (since I don't know for
sure what up$ does), and guess that you need to use a different :TEST
argument (like #':STRING=, maybe) for MEMBER. It defaults to #'EQL,
which isn't going to do the right thing for, say, two strings, or a
string and a symbol. Since SYMBOL-NAME returns a string....

Cheers,
Pillsy
From: Frank Goenninger DG1SBG
Subject: Re: Why oh why does this not work ? (member ...)
Date: 
Message-ID: <lzps0fbra8.fsf@de.goenninger.net>
Pillsy <·········@gmail.com> writes:

> On Sep 18, 5:11 pm, Frank Goenninger DG1SBG <·············@nomail.org>
> wrote:
>> Yeah, I know, I should know why this doesn't work, but I seem to be
>> mind-blocked ...
> [...]
>> Clearly, the (when ...) statement does not fire - but
>> whatever thing I tried ... I can't seem to get the (member ...) tests
>> to return t...
>
> I'm going to take a bit of a stab in the dark (since I don't know for
> sure what up$ does), and guess that you need to use a different :TEST
> argument (like #':STRING=, maybe) for MEMBER. It defaults to #'EQL,
> which isn't going to do the right thing for, say, two strings, or a
> string and a symbol. Since SYMBOL-NAME returns a string....
>
> Cheers,
> Pillsy

Ouch. That does it. Thanks!!

Frank

-- 

  Frank Goenninger

  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."
From: Thomas A. Russ
Subject: Re: Why oh why does this not work ? (member ...)
Date: 
Message-ID: <ymips0e78na.fsf@blackcat.isi.edu>
Frank Goenninger DG1SBG <·············@nomail.org> writes:

> ;; Remark: function up$ returns a string with all characters being
>    UPPER CASE letters 

Why not just use STRING-UPCASE?  It even works with string designators
like symbols.

In general, it's not clear why you are using strings instead of symbols
for your module and function name keys.  Do you find yourself running
into package issues?

> (defun logmsg-fn (msg-class package method method-desc msg &rest msg-args)
>   (format t "~a ~a" (type-of (up$ (symbol-name method))) package)
>   (when (and (member (up$ (symbol-name method)) *debug-functions*)
>              (member *module* *debug-modules*))

  EQL, the default test of MEMBER won't work reliably with strings.
  They would have to be the identical string object.

-- 
Thomas A. Russ,  USC/Information Sciences Institute