This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
logging.go
77 lines (60 loc) · 1.82 KB
/
logging.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// +build ignore
package p9p
import (
"log"
"os"
)
type logging struct {
session Session
logger log.Logger
}
var _ Session = &logging{}
func NewLogger(prefix string, session Session) Session {
return &logging{
session: session,
logger: *log.New(os.Stdout, prefix, 0),
}
}
func (l *logging) Auth(afid Fid, uname, aname string) (Qid, error) {
qid, err := l.session.Auth(afid, uname, aname)
l.logger.Printf("Auth(%v, %s, %s) -> (%v, %v)", afid, uname, aname, qid, err)
return qid, err
}
func (l *logging) Attach(fid, afid Fid, uname, aname string) (Qid, error) {
qid, err := l.session.Attach(fid, afid, uname, aname)
l.logger.Printf("Attach(%v, %v, %s, %s) -> (%v, %v)", fid, afid, uname, aname, qid, err)
return qid, err
}
func (l *logging) Clunk(fid Fid) error {
return l.session.Clunk(fid)
}
func (l *logging) Remove(fid Fid) (err error) {
defer func() {
l.logger.Printf("Remove(%v) -> %v", fid, err)
}()
return l.session.Remove(fid)
}
func (l *logging) Walk(fid Fid, newfid Fid, names ...string) ([]Qid, error) {
return l.session.Walk(fid, newfid, names...)
}
func (l *logging) Read(fid Fid, p []byte, offset int64) (n int, err error) {
return l.session.Read(fid, p, offset)
}
func (l *logging) Write(fid Fid, p []byte, offset int64) (n int, err error) {
return l.session.Write(fid, p, offset)
}
func (l *logging) Open(fid Fid, mode int32) (Qid, error) {
return l.session.Open(fid, mode)
}
func (l *logging) Create(parent Fid, name string, perm uint32, mode uint32) (Qid, error) {
return l.session.Create(parent, name, perm, mode)
}
func (l *logging) Stat(fid Fid) (Dir, error) {
return l.session.Stat(fid)
}
func (l *logging) WStat(fid Fid, dir Dir) error {
return l.session.WStat(fid, dir)
}
func (l *logging) Version(msize int32, version string) (int32, string, error) {
return l.session.Version(msize, version)
}