0

I want to generate logs with time stamp being in place of popups i have mentioned. Please suggest some steps for generating logs with time stamp.

Code:-

click("1450851018693.png")
wait(2)
click(Pattern("1450851091319.png").targetOffset(1,2))
click(Pattern("1450851555941.png").targetOffset(-201,1))
type("111")
click(Pattern("1450851201892.png").targetOffset(-13,2))
type("121")
wait(1)
if exists ("1450851253342.png"):
    popup("start button is enabled")
    click("1450851253342.png")

In the above code instead of popups i want the messages to be logged in file with time stamp. Please Help..

chandu
  • 33
  • 1
  • 8

1 Answers1

1

You can use the logging module from Python importing it and getting a logger instance:

import logging
FORMAT='%(asctime)-15s %(message)s'
logging.basicConfig(format=FORMAT)
logger=logging.getLogger('')

Then, use it in you code (per default, level info is not printed to the console, but warning is)

logger.warning('My message')

You should have a log entry in your like:

2016-03-07 13:10:43,151 My message

See Logging Python for description and basic tutorial.

Loic Mouchard
  • 1,121
  • 7
  • 22