Hey everyone
How would one trace messages from the custom class one that isn't inheriting and smartfox classes? Can I import something? Do I need to extend a base class? Do I need create an object of some sort?
Tracing from custom class.
Is it good practice to keep static reference on SFSExtension class? and call something like that:
MySFSExtension.getInst()._trace("aaa")
or
MySFSExtension._strace("bbb")
MySFSExtension.getInst()._trace("aaa")
or
MySFSExtension._strace("bbb")
Code: Select all
class MySFSExtension extends SFSExtension
{
private static MySFSExtension ext;
public void init()
{
ext= this;
}
public static SFSExtension getInst()
{
return ext;
}
public static void _strace(String msg)
{
getInst()._strace("strace from MySFSExtension : " + msg);
}
public void _trace(String msg)
{
trace("trace from MySFSExtension : " + msg);
}
}
What you have works, but it's opening a Pandora's box - especially once you start having state in that static object.
Log4j is a relatively common logger used in Java and its also what SFS is using directly under the hood whenever you call SFSExtension.trace.
You also get the added benefit of not having tangled dependencies, and the additional ability to categorize your log categories.
Log4j is a relatively common logger used in Java and its also what SFS is using directly under the hood whenever you call SFSExtension.trace.
You also get the added benefit of not having tangled dependencies, and the additional ability to categorize your log categories.
Who is online
Users browsing this forum: No registered users and 88 guests