[go: up one dir, main page]

Menu

[r19]: / logClass.py  Maximize  Restore  History

Download this file

60 lines (46 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import time
from configClass import *
class Logger:
"""
Logger
Provides function to record applications activity, view the log, and
erasing it.
"""
def AddLogEntry(self, entry):
"""
AddLogEntry
Opens the log file and appends a string with
the format date,time : string to it.
The string is received from its argument.
"""
if Config.GetOption("ActLog"):
LogFile = open("data/gEcrit.log", "a")
LogFile.write("\n")
LogFile.write(time.ctime() + " : "+ entry)
LogFile.close()
def EraseLog(self, event):
"""
EraseLog
Opens the log file and erases its contents.
"""
LogFile = open("data/gEcrit.log", "w")
LogFile.write("")
LogFile.close()
def ReadLog(self):
"""
ReadLog
Reads the log file and returns a string with its contents.
"""
LogFile = open("data/gEcrit.log", "r")
logcontent = ""
try:
for line in LogFile.readlines():
logcontent += line
except:
logcontent = ""
return logcontent
Log = Logger()