I've pasted the key, XMPP-related bits below. There really isn't very much
to it :-)

Where my app would have called
   Logger.getLogger(LOGNAME).log(Level.SEVERE, "some logging string");
it now calls
   MyLog.severe("some logging string");

import com.google.appengine.api.xmpp.JID;
import com.google.appengine.api.xmpp.Message;
import com.google.appengine.api.xmpp.MessageBuilder;
import com.google.appengine.api.xmpp.MessageType;
import com.google.appengine.api.xmpp.XMPPService;
import com.google.appengine.api.xmpp.XMPPServiceFactory;

public class MyLog {
private static final String LOGNAME = "cc";
private static boolean invited = false;
private static final XMPPService xmppService = XMPPServiceFactory
.getXMPPService();

public static void severe(String s) {
Logger.getLogger(LOGNAME).log(Level.SEVERE, s);
sendXmpp("SEV!: "+s);
}

public static void warning(String s) {
Logger.getLogger(LOGNAME).log(Level.WARNING, s);
sendXmpp("WARN: "+s);
}

public static void info(String s) {
Logger.getLogger(LOGNAME).log(Level.INFO, s);
                if (Session.isTestUser()) {
 sendXmpp("INFO: "+s);
                }
}

public static void sendXmpp(String s) {
try {
Message message = new MessageBuilder().withRecipientJids(
new JID("sysad...@googlemail.com")).withMessageType(
MessageType.NORMAL).withBody(s).build();
;
if (!invited) {
xmppService.sendInvitation(new JID(
"sysad...@googlemail.com"));
invited = true;
}
xmppService.sendMessage(message);
// }
} catch (Exception e) {
e.printStackTrace();
Logger.getLogger(LOGNAME).log(Level.WARNING, "[L65] jabber exception "+e);
}
}

On Mon, Oct 12, 2009 at 5:21 AM, Andrew Chilton <andychil...@gmail.com>wrote:

>
> Hi Roy,
>
> 2009/10/12 Roy Smith <roy.smith....@googlemail.com>:
> > I run all my logging through a custom Class which duplicates each log
> > message out on XMPP. That way I can debug in real time.
> > It only does the session is a nominated test user so I don;t get
> inundated
> > with log IMs from production users.
>
> Sounds like a nice extension. Would you be allowed and want to share
> it with us? Do you have a link to something which shows what you're
> doing and how you're doing it?
>
> Cheers,
> Andy
>
> --
> contact: Andrew Chilton
> website: http://www.chilts.org/
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to