hi ,

 2

 i had problem in hadling log messages in turbogears

 3

in my log file, the log messages are updated number of times.

 4

for example : when i open the welcome page first time the log message
hello is printed one time, when i refresh the page its get created 2
times more ,again refresh or open the page it print 3 times, its keep
increasing , it should be print only one time whenever the page is
called, but in this case it keep on incrementing.

 5


 6

can anyone help me pls , what wrong in my code.

 7

class logs:

 8

        def ilog(self,status,msg):

 9

                fileName = '/home/antony/Desktop/DAM/Dam/dam.log'

 10

                iHandler = logging.FileHandler(fileName,'a+')

 11


iHandler.setFormatter(logging.Formatter("%(levelname)-8s|%(asctime)s|%(pathname)s,%(name)s,line
%(lineno)s|%(message)s"))

 12

                if status == 'debug':

 13

                        logName='DEBUG'

 14

                        iLog = logging.getLogger(logName)

 15

                        iLog.addHandler(iHandler)

 16

                        iLog.setLevel(logging.DEBUG)

 17

                        iLog.debug(msg)

 18

                elif status == 'info':

 19

                        logName='INFO'

 20

                        iLog = logging.getLogger(logName)

 21

                        iLog.addHandler(iHandler)

 22

                        iLog.setLevel(logging.INFO)

 23

                        iLog.info(msg)

 24

                elif status == 'error':

 25

                        logName='ERROR'

 26

                        iLog = logging.getLogger(logName)

 27

                        iLog.addHandler(iHandler)

 28

                        iLog.setLevel(logging.ERROR)

 29

                        iLog.error(msg)

 30

                else :

 31

                        pass

 32

         33

class Root(controllers.RootController):

 34

    @expose(template="Dam.templates.userManager")

 35

    # @identity.require(identity.in_group("admin"))

 36

    def index(self):

 37

        import time

 38

        l=logs()

 39

        l.ilog("info","hello I m Info")

 40

        return dict(now=time.ctime())

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to