Print object name and method name in log statements

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Print object name and method name in log statements

Stephen Woolerton-2
Hi,

Is there a way to access the name of the current Object, and name of the current method, when a program is running? And if so, is line number accessible too?

I would like this information for logging statements, as a prefix to the log text.

Thanks
Stephen



_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Print object name and method name in log statements

Dmitry Matveev
Hi Stephen,

I am not sure about the line number, but you can always use "self class
name" and something of thisContext (i.e. "thisContext printString") to get
the stack frame details.
If your objects have special (personal) names, it is up to you to implement
the appropriate accessor methods (or a protocol).

With best regards,
Dmitry

2015-02-04 4:06 GMT+03:00 Stephen Woolerton <[hidden email]>:

> Hi,
>
> Is there a way to access the name of the current Object, and name of the
> current method, when a program is running? And if so, is line number
> accessible too?
>
> I would like this information for logging statements, as a prefix to the
> log text.
>
> Thanks
> Stephen
>
>
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-smalltalk
>
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Print object name and method name in log statements

Stephen Woolerton-2
In reply to this post by Stephen Woolerton-2

> Is there a way to access the name of the current Object, and name of the current method, when a program is running?


To answer my own question..

Re printing the name of the current method, BlockClosure has a method for this.
[ ] method
and also can show the object name (the object that is used as ’self’ when executing the receiver)
[ ] receiver
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk