Ajax
ASP
C,C++
C#,.NET
CSS,HTML
Delphi,Kylix
Experience
Flash
Java
JavaScript
PHP
Python
QT
SQL
ShellScript
VB
U :
P :
Register
Lost Password
Other Links
Code Archive
Save Giovanni
Python Category Code
Real Name
:
SharingCode.NET User
Subject
:
A simple logger class
Description
:
A simple logger class
import time class Logger: def __init__(self, filename): self.filename = filename def __call__(self, string): file = open(self.filename, 'a') file.write('[' + time.asctime() + '] ') file.write(string + '\n') file.close() log = Logger('logfile.txt') log('Starting program') log('Trying to divide 1 by 0') print 1 / 0 log('The division succeeded') log('Ending program')
Rating
:
0.00
(out of 5)
Visitor Voting Booth
:
Excellent
Very Good
Good
Fair
Poor
Copyright © 2006 SharingCode.NET . All rights reserved. Hosted By: SisNetworks