GijsTimmers / kotnetcli

An easy automated way to log in on Kotnet.
GNU General Public License v3.0
5 stars 4 forks source link

Add timer in debug mode #81

Closed GijsTimmers closed 8 years ago

GijsTimmers commented 9 years ago

It would be nice to see, how long certain tasks took. e.g.

[DEBUG] t=0.00 kotnetcli initiated
[DEBUG] t=0.23 external modules loaded
[DEBUG] t=0.60 HTTPS connection established
...
GijsTimmers commented 8 years ago

@jovanbulck: maybe you can do some magic with the logging module to get this working?

jovanbulck commented 8 years ago

Added a --time option for this: example usage as follows

$ kotnetcli-dummy --timeout 0.5 --debug --time
[00:53:53.013] DEBUG::kotnetcli: parse_args() is: Namespace(color=False, communicator=None, debug='debug', forget=False, guest_mode=False, institution='kuleuven', keyring=False, license=None, login=100, logout=False, plaintext=False, run_tests=False, time=True, timeout=0.5, version=None)
[00:53:53.013] INFO::kotnetcli_test: ik wil credentials ophalen voor spek en bonen
[00:53:53.013] INFO::kotnetcli_test: ik wil inloggen voor spek en bonen met RC_CODE 100
[00:53:53.013] INFO::kotnetcli: ik ga mee met de stroom
[00:53:53.014] DEBUG::coloramac: Probeert Colorama te importeren...
[00:53:53.015] DEBUG::coloramac: OK
[00:53:53.016] DEBUG::coloramac: the given colornamelist is ['GREEN', 'YELLOW', 'RED', 'BRIGHT']
[00:53:53.016] DEBUG::worker: enter LoginWorker.go()
Kotnetverbinding testen.... [ OK ]
Netlogin openen............ [ OK ]
Gegevens invoeren.......... [ OK ]
Gegevens opsturen.......... [ OK ]
[00:53:54.518] DEBUG::browser: rccode is 100
Download:  [=======        ][ 44%]
Upload:    [=============  ][ 85%]
Inloggen................... [DONE]
[00:53:54.519] DEBUG::worker: LoginWorker: exiting with success

A relative timer (with offset from start) would be even better of course, but it seems more difficult to achieve -- we may be able to use a custom Logging.Formatter class. As the above commit does the job, I am closing this issue now. Feel free to re-open if more specific functionality is required...