1 4b33cdd0 2015-11-30 stephen.d // +build ignore
3 4b33cdd0 2015-11-30 stephen.d package p9p
5 4b33cdd0 2015-11-30 stephen.d import (
10 4b33cdd0 2015-11-30 stephen.d type logging struct {
11 4b33cdd0 2015-11-30 stephen.d session Session
12 4b33cdd0 2015-11-30 stephen.d logger log.Logger
15 4b33cdd0 2015-11-30 stephen.d var _ Session = &logging{}
17 4b33cdd0 2015-11-30 stephen.d func NewLogger(prefix string, session Session) Session {
18 4b33cdd0 2015-11-30 stephen.d return &logging{
19 4b33cdd0 2015-11-30 stephen.d session: session,
20 4b33cdd0 2015-11-30 stephen.d logger: *log.New(os.Stdout, prefix, 0),
24 4b33cdd0 2015-11-30 stephen.d func (l *logging) Auth(afid Fid, uname, aname string) (Qid, error) {
25 4b33cdd0 2015-11-30 stephen.d qid, err := l.session.Auth(afid, uname, aname)
26 4b33cdd0 2015-11-30 stephen.d l.logger.Printf("Auth(%v, %s, %s) -> (%v, %v)", afid, uname, aname, qid, err)
27 4b33cdd0 2015-11-30 stephen.d return qid, err
30 4b33cdd0 2015-11-30 stephen.d func (l *logging) Attach(fid, afid Fid, uname, aname string) (Qid, error) {
31 4b33cdd0 2015-11-30 stephen.d qid, err := l.session.Attach(fid, afid, uname, aname)
32 4b33cdd0 2015-11-30 stephen.d l.logger.Printf("Attach(%v, %v, %s, %s) -> (%v, %v)", fid, afid, uname, aname, qid, err)
33 4b33cdd0 2015-11-30 stephen.d return qid, err
36 4b33cdd0 2015-11-30 stephen.d func (l *logging) Clunk(fid Fid) error {
37 4b33cdd0 2015-11-30 stephen.d return l.session.Clunk(fid)
40 4b33cdd0 2015-11-30 stephen.d func (l *logging) Remove(fid Fid) (err error) {
41 4b33cdd0 2015-11-30 stephen.d defer func() {
42 4b33cdd0 2015-11-30 stephen.d l.logger.Printf("Remove(%v) -> %v", fid, err)
44 4b33cdd0 2015-11-30 stephen.d return l.session.Remove(fid)
47 4b33cdd0 2015-11-30 stephen.d func (l *logging) Walk(fid Fid, newfid Fid, names ...string) ([]Qid, error) {
48 4b33cdd0 2015-11-30 stephen.d return l.session.Walk(fid, newfid, names...)
51 4b33cdd0 2015-11-30 stephen.d func (l *logging) Read(fid Fid, p []byte, offset int64) (n int, err error) {
52 4b33cdd0 2015-11-30 stephen.d return l.session.Read(fid, p, offset)
55 4b33cdd0 2015-11-30 stephen.d func (l *logging) Write(fid Fid, p []byte, offset int64) (n int, err error) {
56 4b33cdd0 2015-11-30 stephen.d return l.session.Write(fid, p, offset)
59 4b33cdd0 2015-11-30 stephen.d func (l *logging) Open(fid Fid, mode int32) (Qid, error) {
60 4b33cdd0 2015-11-30 stephen.d return l.session.Open(fid, mode)
63 4b33cdd0 2015-11-30 stephen.d func (l *logging) Create(parent Fid, name string, perm uint32, mode uint32) (Qid, error) {
64 4b33cdd0 2015-11-30 stephen.d return l.session.Create(parent, name, perm, mode)
67 4b33cdd0 2015-11-30 stephen.d func (l *logging) Stat(fid Fid) (Dir, error) {
68 4b33cdd0 2015-11-30 stephen.d return l.session.Stat(fid)
71 4b33cdd0 2015-11-30 stephen.d func (l *logging) WStat(fid Fid, dir Dir) error {
72 4b33cdd0 2015-11-30 stephen.d return l.session.WStat(fid, dir)
75 4b33cdd0 2015-11-30 stephen.d func (l *logging) Version(msize int32, version string) (int32, string, error) {
76 4b33cdd0 2015-11-30 stephen.d return l.session.Version(msize, version)