File: log_simple_module.py

package info (click to toggle)
pyftpd 0.8.4.3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 528 kB
  • ctags: 470
  • sloc: python: 2,802; sh: 80; makefile: 43
file content (26 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (2)
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
import time, sys

from log_simple_config import *

class Log:

    def openlog(self):
        global logfile
        if not logfile:
            if sys.platform[:3] == 'win':
                logfile = "c:/pyftpd.log"
            else:
                logfile = "/tmp/pyftpd.log"
        self.logfile = open(logfile, "a")
        
    def log(self, t, user, ip, command, boe): # time, who, ip, command, beginning=0 or end=1
        line = "%s %s@%s %s %i\n" % (time.ctime(t), user, ip, command, boe)
        self.logfile.write(line)
        self.logfile.flush()

    def closelog(self):
        self.logfile.close()

    def __del__(self):
        self.logfile.close()