Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Logging/Tracing in GLOs  (Read 1485 times)
0 Members and 1 Guest are viewing this topic.
Offline BettyJoNabisco

Junior Newbie





« Posted 2007-02-19 03:26:23 »

Hello, SGS Community,

I'm experimenting with SGS, and have put together a boot GLO and am trying to make it work.  Following the SworldWorld code for the most part.  I can start up the server with my game, and I have a client which connects to the server fine.  However, the problem I am having is that, even though the boot GLO is registering as a SimUserListener, I am not seeing my userJoined method being called when my client logs in.

I base this on the fact that I am using a java.util.logging.Logger in the boot GLO to log info to a file.  I create the Logger in the boot() method, and store a reference to it in a member of the boot GLO.  I have logging calls in both the boot() method and the userJoined() method.  I see the logging from the boot() method in the log file, but I don't see the logging from the userJoined() method.

The Logger class is not serializable, so I have to declare the 'Logger logger' boot GLO member transient.  I was wondering if this works for persistent objects.  If the Boot GLO is serialized to the Store and later de-serialized from the Store, then the transient member would be uninitialized.  I suppose I really need to address this at some point, but I'm wondering right now if this is the source of the problem I have with the userJoined() method apparently not getting called.  Maybe it *is* getting called, but the logging is not working because of serialization.

The real problem is gaining visibility into what the Server is doing.  Does anybody have any advice on how to address the subject of logging in GLOs?

Thanks...BJN

Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #1 - Posted 2007-02-19 12:54:11 »

Hi

I've done similar things. I used apache commons logging instead, but it's the same principle. You can take a look at the subversion repository here. Take a look at the DVSFBoot and DVSFUserListener classes.

HTH

Endolf

Offline BettyJoNabisco

Junior Newbie





« Reply #2 - Posted 2007-02-19 16:22:15 »

Endolf,

Thanks for the reply.  I notice that you declare your Logger member as 'transient final".  I'm not sure of the consequences of doing that.  That is not what I tried to finally make it work.  Here's my solution.

Original boot GLO was something like:
public class BootGLO implements BLAH... {
  private transient Logger logger;

  public void boot(blah) {
    logger = Logger.getLogger(blah);
    logger.fine("boot");
    blah...
   }

  public void userJoined(blah) {
    logger.fine("userJoined");
   blah...
  }
}

I was seeing the "boot" log message but not the "userJoined".  And I was not seeing any null pointer exceptions.

Changed this as follows:
public class BootGLO implements BLAH... {
 
  public void boot(blah) {
     Logger logger = MyLogManager.getLogger(blah);
     logger.fine("boot");
     blah...
   }

  public void userJoined(blah) {
    Logger logger = MyLogManager.getLogger(blah);
     logger.fine("userJoined");
   blah...
  }
}

public class MyLogManager {
  static HashMap<String, Logger> logMap = new HashMap(blah);
  public static Logger getLogger(String name) {
    Logger logger = logMap.get(name);
    if (logger == null) {
      logger = create and configure new Logger
      logMap.put(name, logger);
    }
    return logger;
  }
}

The lesson I've learned is to avoid using transient members in GLOs.  Instead, pass the job off to components that can recreate the transient service when and if required.  Again, not sure if doing  your "final transient" solution would have worked as well.  Obviously, it works for you.  I'll give it a try when I get a chance.  Again, thanks.


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #3 - Posted 2007-02-19 18:47:29 »

I think the important bit is that it's a static member.

Endolf

Offline Mr_Light

Senior Member


Medals: 1


shiny.


« Reply #4 - Posted 2007-02-19 20:03:57 »

err, just use the deserialise method to get a logger?

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #5 - Posted 2007-02-19 22:54:52 »

I use private static final loggers in my normal classes, so it makes sense to me to use static loggers in my GLOs. It's worked so far by just making them transient.

Endolf

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (35 views)
2014-09-24 16:13:29

Pippogeek (28 views)
2014-09-24 16:12:22

Pippogeek (17 views)
2014-09-24 16:12:06

Grunnt (40 views)
2014-09-23 14:38:19

radar3301 (23 views)
2014-09-21 23:33:17

BurntPizza (59 views)
2014-09-21 02:42:18

BurntPizza (29 views)
2014-09-21 01:30:30

moogie (34 views)
2014-09-21 00:26:15

UprightPath (47 views)
2014-09-20 20:14:06

BurntPizza (51 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!