Comment #6 on issue 456 by pekka.klarck: When logging messages through stdout timestamps are not accurate
http://code.google.com/p/robotframework/issues/detail?id=456

I've been thinking this a bit more and believe adding support for embedding the timestamp to the message (option 2) in my previous comment) is enough. The implementation is so much easier than trying to add timestamps automatically and a single implementation would support all library types including remote libraries.

I think a good way to specify the time is using epoch time and something like 2010-05-09 12:51:01.123, though. Because the resulting timestamp contains milliseconds, it's probably fair to ask the epoch time to be given in millis too. That's easy to do both in Python and in Java:

    def example_keyword():
        print '*INFO:%s* Hello, world' % (time.time()*1000)

    public void exampleKeyword() {
System.out.println("*INFO:" + System.currentTimeMillis() + "* Hello, world!";
    }

For a user this is obviously slightly more complicated than getting a correct timestamp automatically but I don't think that matters because: 1) You can have a single logger method (or even separate logger class) that your library uses and thus only need to give the time once.
2) As seen by above examples actually giving the time is next to trivial.
3) You can also use new `robot.logging.api` (issue 339) or `logging` (issue 456) APIs and get accurate timestamps automatically. 4) In most cases not having an exactly correct timestamp doesn't really matter in the first place.

Reply via email to