File: log_format_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 (24 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import time, sys

import log_simple_module

class Log(log_simple_module.Log):

    def log(self, t, user, ip, command, boe): # time, who, ip, command, beginning=0 or end=1
        if command[:4] == "PASS" and user not in ("anonymous", "ftp"):
            command = "PASS (hidden)"
        event = {'t':time.ctime(t),
                 'user': user,
                 'cmd': command,
                 'ip': ip
                 }
        if boe == 0: #begin
            line = '%(t)s:start "%(cmd)s" from %(user)s@%(ip)s ' % event
        elif boe == 1: #end
            line = '%(t)s:stop  "%(cmd)s" from %(user)s@%(ip)s ' % event
        else:
            line = '%(t)s:      "%(cmd)s" from %(user)s@%(ip)s ' % event
        self.logfile.write(line+"\n")
        self.logfile.flush()