#!/usr/bin/env python
# $ID$
import CORBA, sys, string, time
from string import split, strip, joinfields
from time import localtime, strftime, time
# Here are the functions to support the Log interface
class Log:   # interface
    def addlog (self, info):
	logfile = open("./logs.log", "a")
	logfile.write(joinfields([info.hostname,
				  strftime("%Y/%m/%d %H:%M:%S %Z", 
					   localtime(time())), 
				  info.userid, info.application,
				  info.messagetype, info.shortmessage], "|"))
	logfile.write("\n")
	logfile.close()

CORBA.load_idl("logger.idl")
orb = CORBA.ORB_init((), CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")

servant = POA.LOG.LOG(Log())
poa.activate_object(servant)
ref = poa.servant_to_reference(servant)
open("./logger.ior", "w").write(orb.object_to_string(ref))

print "Done initialization: Proceed!"
poa.the_POAManager.activate()
orb.run()
