-
Notifications
You must be signed in to change notification settings - Fork 4
/
null_logger.go
45 lines (35 loc) · 1.07 KB
/
null_logger.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
package logger
import (
"fmt"
"github.com/stuartcarnie/gopm/faults"
)
// NullLogger discard the program stdout/stderr log
type NullLogger struct{}
// NewNullLogger creates a NullLogger
func NewNullLogger() *NullLogger {
return &NullLogger{}
}
// Write write the log to this logger
func (l *NullLogger) Write(p []byte) (int, error) {
return len(p), nil
}
// Close close the logger
func (l *NullLogger) Close() error {
return nil
}
// ReadLog read the log, return error
func (l *NullLogger) ReadLog(offset, length int64) (string, error) {
return "", faults.NewFault(faults.NoFile, "NO_FILE")
}
// ReadTailLog tail the log, return error
func (l *NullLogger) ReadTailLog(offset, length int64) (string, int64, bool, error) {
return "", 0, false, faults.NewFault(faults.NoFile, "NO_FILE")
}
// ClearCurLogFile close current log file, return error
func (l *NullLogger) ClearCurLogFile() error {
return fmt.Errorf("no log")
}
// ClearAllLogFile clear all the lof file, return error
func (l *NullLogger) ClearAllLogFile() error {
return faults.NewFault(faults.NoFile, "NO_FILE")
}