forked from MG-RAST/graval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftplogger.go
37 lines (30 loc) · 805 Bytes
/
ftplogger.go
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
package graval
import (
"fmt"
"log"
)
// Use an instance of this to log in a standard format
type ftpLogger struct {
sessionId string
}
func newFtpLogger(id string) *ftpLogger {
l := new(ftpLogger)
l.sessionId = id
return l
}
func (logger *ftpLogger) Print(message interface{}) {
log.Printf("%s %s", logger.sessionId, message)
}
func (logger *ftpLogger) Printf(format string, v ...interface{}) {
logger.Print(fmt.Sprintf(format, v...))
}
func (logger *ftpLogger) PrintCommand(command string, params string) {
if command == "PASS" {
log.Printf("%s > PASS ****", logger.sessionId)
} else {
log.Printf("%s > %s %s", logger.sessionId, command, params)
}
}
func (logger *ftpLogger) PrintResponse(code int, message string) {
log.Printf("%s < %d %s", logger.sessionId, code, message)
}