x/lib/vlog: remove interface definitions that are now in v23/logging.
MultiPart: 3/3
Change-Id: I69db93e6032d744eb0e96d8c2cba3029c81437e2
diff --git a/vlog/.api b/vlog/.api
index d4e2286..c34ae9a 100644
--- a/vlog/.api
+++ b/vlog/.api
@@ -1,6 +1,5 @@
pkg vlog, func Configure(...LoggingOpts) error
pkg vlog, func ConfigureLibraryLoggerFromFlags() error
-pkg vlog, func ConfigureLoggerFromFlags(Logger) error
pkg vlog, func Error(...interface{})
pkg vlog, func ErrorDepth(int, ...interface{})
pkg vlog, func Errorf(string, ...interface{})
@@ -12,17 +11,38 @@
pkg vlog, func InfoDepth(int, ...interface{})
pkg vlog, func InfoStack(bool)
pkg vlog, func Infof(string, ...interface{})
-pkg vlog, func InfofDepth(int, string, ...interface{})
-pkg vlog, func NewLogger(string) Logger
+pkg vlog, func NewLogger(string) *Logger
pkg vlog, func Panic(...interface{})
pkg vlog, func PanicDepth(int, ...interface{})
pkg vlog, func Panicf(string, ...interface{})
-pkg vlog, func Stats() LevelStats
+pkg vlog, func Stats() (struct{ Lines, Bytes int64 }, struct{ Lines, Bytes int64 })
pkg vlog, func V(Level) bool
-pkg vlog, func VI(Level) InfoLog
+pkg vlog, func VI(Level) interface { Info(args ...interface{});; Infof(format string, args ...interface{});; InfoDepth(depth int, args ...interface{});; InfoStack(all bool);}
pkg vlog, method (*Level) Get(string) interface{}
pkg vlog, method (*Level) Set(string) error
pkg vlog, method (*Level) String() string
+pkg vlog, method (*Logger) Configure(...LoggingOpts) error
+pkg vlog, method (*Logger) ConfigureFromFlags() error
+pkg vlog, method (*Logger) Error(...interface{})
+pkg vlog, method (*Logger) ErrorDepth(int, ...interface{})
+pkg vlog, method (*Logger) Errorf(string, ...interface{})
+pkg vlog, method (*Logger) ExplicitlySetFlags() map[string]string
+pkg vlog, method (*Logger) Fatal(...interface{})
+pkg vlog, method (*Logger) FatalDepth(int, ...interface{})
+pkg vlog, method (*Logger) Fatalf(string, ...interface{})
+pkg vlog, method (*Logger) FlushLog()
+pkg vlog, method (*Logger) Info(...interface{})
+pkg vlog, method (*Logger) InfoDepth(int, ...interface{})
+pkg vlog, method (*Logger) InfoStack(bool)
+pkg vlog, method (*Logger) Infof(string, ...interface{})
+pkg vlog, method (*Logger) LogDir() string
+pkg vlog, method (*Logger) Panic(...interface{})
+pkg vlog, method (*Logger) PanicDepth(int, ...interface{})
+pkg vlog, method (*Logger) Panicf(string, ...interface{})
+pkg vlog, method (*Logger) Stats() (struct{ Lines, Bytes int64 }, struct{ Lines, Bytes int64 })
+pkg vlog, method (*Logger) String() string
+pkg vlog, method (*Logger) V(int) bool
+pkg vlog, method (*Logger) VI(int) interface { Info(args ...interface{});; Infof(format string, args ...interface{});; InfoDepth(depth int, args ...interface{});; InfoStack(all bool);}
pkg vlog, method (*StderrThreshold) Get(string) interface{}
pkg vlog, method (*StderrThreshold) Set(string) error
pkg vlog, method (*StderrThreshold) String() string
@@ -41,37 +61,10 @@
pkg vlog, type AutoFlush bool
pkg vlog, type FilepathSpec struct
pkg vlog, type FilepathSpec struct, embedded llog.FilepathSpec
-pkg vlog, type InfoLog interface { Info, InfoDepth, InfoStack, Infof, InfofDepth }
-pkg vlog, type InfoLog interface, Info(...interface{})
-pkg vlog, type InfoLog interface, InfoDepth(int, ...interface{})
-pkg vlog, type InfoLog interface, InfoStack(bool)
-pkg vlog, type InfoLog interface, Infof(string, ...interface{})
-pkg vlog, type InfoLog interface, InfofDepth(int, string, ...interface{})
pkg vlog, type Level llog.Level
-pkg vlog, type LevelStats llog.Stats
pkg vlog, type LogDir string
pkg vlog, type LogToStderr bool
-pkg vlog, type Logger interface { Configure, Error, ErrorDepth, Errorf, Fatal, FatalDepth, Fatalf, FlushLog, Info, InfoDepth, InfoStack, Infof, InfofDepth, LogDir, Panic, PanicDepth, Panicf, Stats, V, VI }
-pkg vlog, type Logger interface, Configure(...LoggingOpts) error
-pkg vlog, type Logger interface, Error(...interface{})
-pkg vlog, type Logger interface, ErrorDepth(int, ...interface{})
-pkg vlog, type Logger interface, Errorf(string, ...interface{})
-pkg vlog, type Logger interface, Fatal(...interface{})
-pkg vlog, type Logger interface, FatalDepth(int, ...interface{})
-pkg vlog, type Logger interface, Fatalf(string, ...interface{})
-pkg vlog, type Logger interface, FlushLog()
-pkg vlog, type Logger interface, Info(...interface{})
-pkg vlog, type Logger interface, InfoDepth(int, ...interface{})
-pkg vlog, type Logger interface, InfoStack(bool)
-pkg vlog, type Logger interface, Infof(string, ...interface{})
-pkg vlog, type Logger interface, InfofDepth(int, string, ...interface{})
-pkg vlog, type Logger interface, LogDir() string
-pkg vlog, type Logger interface, Panic(...interface{})
-pkg vlog, type Logger interface, PanicDepth(int, ...interface{})
-pkg vlog, type Logger interface, Panicf(string, ...interface{})
-pkg vlog, type Logger interface, Stats() LevelStats
-pkg vlog, type Logger interface, V(Level) bool
-pkg vlog, type Logger interface, VI(Level) InfoLog
+pkg vlog, type Logger struct
pkg vlog, type LoggingOpts interface { LoggingOpt }
pkg vlog, type LoggingOpts interface, LoggingOpt()
pkg vlog, type MaxStackBufSize int
@@ -81,8 +74,5 @@
pkg vlog, type StderrThreshold llog.Severity
pkg vlog, type TraceLocation struct
pkg vlog, type TraceLocation struct, embedded llog.TraceLocation
-pkg vlog, type Verbosity interface { V, VI }
-pkg vlog, type Verbosity interface, V(Level) bool
-pkg vlog, type Verbosity interface, VI(Level) InfoLog
pkg vlog, var ErrConfigured error
-pkg vlog, var Log *logger
+pkg vlog, var Log *Logger
diff --git a/vlog/flags.go b/vlog/flags.go
index 86b6ced..3a3c312 100644
--- a/vlog/flags.go
+++ b/vlog/flags.go
@@ -75,12 +75,16 @@
// using command line flags. It assumes that flag.Parse() has already been
// called to initialize the flag variables.
func ConfigureLibraryLoggerFromFlags() error {
- return ConfigureLoggerFromFlags(Log)
+ return Log.ConfigureFromFlags()
}
-// ConfigureLoggerFromLogs will configure the supplied logger using
+func (l *Logger) String() string {
+ return l.log.String()
+}
+
+// ConfigureLoggerFromFlags will configure the logger using
// command line flags.
-func ConfigureLoggerFromFlags(l Logger) error {
+func (l *Logger) ConfigureFromFlags() error {
return l.Configure(
LogToStderr(toStderr),
AlsoLogToStderr(alsoToStderr),
@@ -94,15 +98,11 @@
)
}
-func (l *logger) String() string {
- return l.log.String()
-}
-
// ExplicitlySetFlags returns a map of the logging command line flags and their
// values formatted as strings. Only the flags that were explicitly set are
// returned. This is intended for use when an application needs to know what
// value the flags were set to, for example when creating subprocesses.
-func (l *logger) ExplicitlySetFlags() map[string]string {
+func (l *Logger) ExplicitlySetFlags() map[string]string {
logFlagNames := make(map[string]bool)
for _, flagDef := range flagDefs {
logFlagNames[flagDef.name] = true
diff --git a/vlog/flags_test.go b/vlog/flags_test.go
index 37c73db..ad23e83 100644
--- a/vlog/flags_test.go
+++ b/vlog/flags_test.go
@@ -12,6 +12,7 @@
"testing"
"v.io/x/lib/vlog"
+
"v.io/x/ref/test/modules"
)
diff --git a/vlog/funcs.go b/vlog/funcs.go
index c7c7e23..8bfa617 100644
--- a/vlog/funcs.go
+++ b/vlog/funcs.go
@@ -29,13 +29,6 @@
Log.maybeFlush()
}
-// InfofDepth acts as Infof but uses depth to determine which call frame to log.
-// A depth of 0 is equivalent to calling Infof.
-func InfofDepth(depth int, format string, args ...interface{}) {
- Log.log.PrintfDepth(llog.InfoLog, depth, format, args...)
- Log.maybeFlush()
-}
-
// InfoStack logs the current goroutine's stack if the all parameter
// is false, or the stacks of all goroutines if it's true.
func InfoStack(all bool) {
@@ -51,7 +44,23 @@
// interface that will either log (if level >= the configured level)
// or discard its parameters. This allows for logger.VI(2).Info
// style usage.
-func VI(level Level) InfoLog {
+func VI(level Level) interface {
+ // Info logs to the INFO log.
+ // Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
+ Info(args ...interface{})
+
+ // Infoln logs to the INFO log.
+ // Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
+ Infof(format string, args ...interface{})
+
+ // InfoDepth acts as Info but uses depth to determine which call frame to log.
+ // A depth of 0 is equivalent to calling Info.
+ InfoDepth(depth int, args ...interface{})
+
+ // InfoStack logs the current goroutine's stack if the all parameter
+ // is false, or the stacks of all goroutines if it's true.
+ InfoStack(all bool)
+} {
if Log.log.V(llog.Level(level)) {
return Log
}
@@ -115,7 +124,7 @@
// Stats returns stats on how many lines/bytes haven been written to
// this set of logs.
-func Stats() LevelStats {
+func Stats() (Info, Error struct{ Lines, Bytes int64 }) {
return Log.Stats()
}
diff --git a/vlog/log.go b/vlog/log.go
index d5a7a33..1d2d288 100644
--- a/vlog/log.go
+++ b/vlog/log.go
@@ -18,7 +18,72 @@
initialMaxStackBufSize = 128 * 1024
)
-type logger struct {
+// Level specifies a level of verbosity for V logs.
+// It can be set via the Level optional parameter to Configure.
+// It implements the flag.Value interface to support command line option parsing.
+type Level llog.Level
+
+// Set is part of the flag.Value interface.
+func (l *Level) Set(v string) error {
+ return (*llog.Level)(l).Set(v)
+}
+
+// Get is part of the flag.Value interface.
+func (l *Level) Get(v string) interface{} {
+ return *l
+}
+
+// String is part of the flag.Value interface.
+func (l *Level) String() string {
+ return (*llog.Level)(l).String()
+}
+
+// StderrThreshold identifies the sort of log: info, warning etc.
+// The values match the corresponding constants in C++ - e.g WARNING etc.
+// It can be set via the StderrThreshold optional parameter to Configure.
+// It implements the flag.Value interface to support command line option parsing.
+type StderrThreshold llog.Severity
+
+// Set is part of the flag.Value interface.
+func (s *StderrThreshold) Set(v string) error {
+ return (*llog.Severity)(s).Set(v)
+}
+
+// Get is part of the flag.Value interface.
+func (s *StderrThreshold) Get(v string) interface{} {
+ return *s
+}
+
+// String is part of the flag.Value interface.
+func (s *StderrThreshold) String() string {
+ return (*llog.Severity)(s).String()
+}
+
+// ModuleSpec allows for the setting of specific log levels for specific
+// modules. The syntax is recordio=2,file=1,gfs*=3
+// It can be set via the ModuleSpec optional parameter to Configure.
+// It implements the flag.Value interface to support command line option parsing.
+type ModuleSpec struct {
+ llog.ModuleSpec
+}
+
+// FilepathSpec allows for the setting of specific log levels for specific
+// files matched by a regular expression. The syntax is <re>=3,<re1>=2.
+// It can be set via the FilepathSpec optional parameter to Configure.
+// It implements the flag.Value interface to support command line option parsing.
+type FilepathSpec struct {
+ llog.FilepathSpec
+}
+
+// TraceLocation specifies the location, file:N, which when encountered will
+// cause logging to emit a stack trace.
+// It can be set via the TraceLocation optional parameter to Configure.
+// It implements the flag.Value interface to support command line option parsing.
+type TraceLocation struct {
+ llog.TraceLocation
+}
+
+type Logger struct {
log *llog.Log
mu sync.Mutex // guards updates to the vars below.
autoFlush bool
@@ -27,27 +92,27 @@
configured bool
}
-func (l *logger) maybeFlush() {
+func (l *Logger) maybeFlush() {
if l.autoFlush {
l.log.Flush()
}
}
var (
- Log *logger
+ Log *Logger
ErrConfigured = errors.New("logger has already been configured")
)
const stackSkip = 1
func init() {
- Log = &logger{log: llog.NewLogger("vanadium", stackSkip)}
+ Log = &Logger{log: llog.NewLogger("vlog", stackSkip)}
}
// NewLogger creates a new instance of the logging interface.
-func NewLogger(name string) Logger {
+func NewLogger(name string) *Logger {
// Create an instance of the runtime with just logging enabled.
- return &logger{log: llog.NewLogger(name, stackSkip)}
+ return &Logger{log: llog.NewLogger(name, stackSkip)}
}
// Configure configures all future logging. Some options
@@ -55,7 +120,7 @@
// in which case an error will be returned. The Configured error is returned
// if ConfigureLogger has already been called unless the
// OverridePriorConfiguration options is included.
-func (l *logger) Configure(opts ...LoggingOpts) error {
+func (l *Logger) Configure(opts ...LoggingOpts) error {
l.mu.Lock()
defer l.mu.Unlock()
override := false
@@ -102,7 +167,7 @@
}
// LogDir returns the directory where the log files are written.
-func (l *logger) LogDir() string {
+func (l *Logger) LogDir() string {
if len(l.logDir) != 0 {
return l.logDir
}
@@ -111,39 +176,34 @@
// Stats returns stats on how many lines/bytes haven been written to
// this set of logs.
-func (l *logger) Stats() LevelStats {
- return LevelStats(l.log.Stats())
+func (l *Logger) Stats() (Info, Error struct{ Lines, Bytes int64 }) {
+ stats := l.log.Stats()
+ return struct{ Lines, Bytes int64 }{Lines: stats.Info.Lines(), Bytes: stats.Info.Bytes()},
+ struct{ Lines, Bytes int64 }{Lines: stats.Error.Lines(), Bytes: stats.Error.Bytes()}
}
// Info logs to the INFO log.
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
-func (l *logger) Info(args ...interface{}) {
+func (l *Logger) Info(args ...interface{}) {
l.log.Print(llog.InfoLog, args...)
l.maybeFlush()
}
// Infof logs to the INFO log.
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
-func (l *logger) Infof(format string, args ...interface{}) {
+func (l *Logger) Infof(format string, args ...interface{}) {
l.log.Printf(llog.InfoLog, format, args...)
l.maybeFlush()
}
// InfoDepth acts as Info but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Info.
-func (l *logger) InfoDepth(depth int, args ...interface{}) {
+func (l *Logger) InfoDepth(depth int, args ...interface{}) {
l.log.PrintDepth(llog.InfoLog, depth, args...)
l.maybeFlush()
}
-// InfofDepth acts as Infof but uses depth to determine which call frame to log.
-// A depth of 0 is equivalent to calling Infof.
-func (l *logger) InfofDepth(depth int, format string, args ...interface{}) {
- l.log.PrintfDepth(llog.InfoLog, depth, format, args...)
- l.maybeFlush()
-}
-
-func infoStack(l *logger, all bool) {
+func infoStack(l *Logger, all bool) {
n := initialMaxStackBufSize
var trace []byte
for n <= l.maxStackBufSize {
@@ -161,23 +221,38 @@
// InfoStack logs the current goroutine's stack if the all parameter
// is false, or the stacks of all goroutines if it's true.
-func (l *logger) InfoStack(all bool) {
+func (l *Logger) InfoStack(all bool) {
infoStack(l, all)
}
-func (l *logger) V(v Level) bool {
+func (l *Logger) V(v int) bool {
return l.log.V(llog.Level(v))
}
type discardInfo struct{}
-func (_ *discardInfo) Info(...interface{}) {}
-func (_ *discardInfo) Infof(_ string, _ ...interface{}) {}
-func (_ *discardInfo) InfoDepth(_ int, _ ...interface{}) {}
-func (_ *discardInfo) InfofDepth(_ int, _ string, _ ...interface{}) {}
-func (_ *discardInfo) InfoStack(_ bool) {}
+func (_ *discardInfo) Info(...interface{}) {}
+func (_ *discardInfo) Infof(_ string, _ ...interface{}) {}
+func (_ *discardInfo) InfoDepth(_ int, _ ...interface{}) {}
+func (_ *discardInfo) InfoStack(_ bool) {}
-func (l *logger) VI(v Level) InfoLog {
+func (l *Logger) VI(v int) interface {
+ // Info logs to the INFO log.
+ // Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
+ Info(args ...interface{})
+
+ // Infoln logs to the INFO log.
+ // Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
+ Infof(format string, args ...interface{})
+
+ // InfoDepth acts as Info but uses depth to determine which call frame to log.
+ // A depth of 0 is equivalent to calling Info.
+ InfoDepth(depth int, args ...interface{})
+
+ // InfoStack logs the current goroutine's stack if the all parameter
+ // is false, or the stacks of all goroutines if it's true.
+ InfoStack(all bool)
+} {
if l.log.V(llog.Level(v)) {
return l
}
@@ -185,27 +260,27 @@
}
// Flush flushes all pending log I/O.
-func (l *logger) FlushLog() {
+func (l *Logger) FlushLog() {
l.log.Flush()
}
// Error logs to the ERROR and INFO logs.
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
-func (l *logger) Error(args ...interface{}) {
+func (l *Logger) Error(args ...interface{}) {
l.log.Print(llog.ErrorLog, args...)
l.maybeFlush()
}
// ErrorDepth acts as Error but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Error.
-func (l *logger) ErrorDepth(depth int, args ...interface{}) {
+func (l *Logger) ErrorDepth(depth int, args ...interface{}) {
l.log.PrintDepth(llog.ErrorLog, depth, args...)
l.maybeFlush()
}
// Errorf logs to the ERROR and INFO logs.
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
-func (l *logger) Errorf(format string, args ...interface{}) {
+func (l *Logger) Errorf(format string, args ...interface{}) {
l.log.Printf(llog.ErrorLog, format, args...)
l.maybeFlush()
}
@@ -213,38 +288,38 @@
// Fatal logs to the FATAL, ERROR and INFO logs,
// including a stack trace of all running goroutines, then calls os.Exit(255).
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
-func (l *logger) Fatal(args ...interface{}) {
+func (l *Logger) Fatal(args ...interface{}) {
l.log.Print(llog.FatalLog, args...)
}
// FatalDepth acts as Fatal but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Fatal.
-func (l *logger) FatalDepth(depth int, args ...interface{}) {
+func (l *Logger) FatalDepth(depth int, args ...interface{}) {
l.log.PrintDepth(llog.FatalLog, depth, args...)
}
// Fatalf logs to the FATAL, ERROR and INFO logs,
// including a stack trace of all running goroutines, then calls os.Exit(255).
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
-func (l *logger) Fatalf(format string, args ...interface{}) {
+func (l *Logger) Fatalf(format string, args ...interface{}) {
l.log.Printf(llog.FatalLog, format, args...)
}
// Panic is equivalent to Error() followed by a call to panic().
-func (l *logger) Panic(args ...interface{}) {
+func (l *Logger) Panic(args ...interface{}) {
l.Error(args...)
panic(fmt.Sprint(args...))
}
// PanicDepth acts as Panic but uses depth to determine which call frame to log.
// A depth of 0 is equivalent to calling Panic.
-func (l *logger) PanicDepth(depth int, args ...interface{}) {
+func (l *Logger) PanicDepth(depth int, args ...interface{}) {
l.ErrorDepth(depth, args...)
panic(fmt.Sprint(args...))
}
// Panicf is equivalent to Errorf() followed by a call to panic().
-func (l *logger) Panicf(format string, args ...interface{}) {
+func (l *Logger) Panicf(format string, args ...interface{}) {
l.Errorf(format, args...)
panic(fmt.Sprintf(format, args...))
}
diff --git a/vlog/log_test.go b/vlog/log_test.go
index 5468ca4..00def8f 100644
--- a/vlog/log_test.go
+++ b/vlog/log_test.go
@@ -125,6 +125,7 @@
}
}
}
+
func TestVModule(t *testing.T) {
dir, err := ioutil.TempDir("", "logtest")
defer os.RemoveAll(dir)
@@ -232,3 +233,33 @@
t.Fatalf("got %v, want %v", got, want)
}
}
+
+func TestStats(t *testing.T) {
+ dir, err := ioutil.TempDir("", "logtest")
+ defer os.RemoveAll(dir)
+ if err != nil {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ logger := vlog.NewLogger("testStats")
+ logger.Configure(vlog.LogDir(dir))
+ logger.Info("line 1")
+ logger.Info("line 2")
+ logger.Error("error 1")
+
+ infoStats, errorStats := logger.Stats()
+ expected := []struct{ Lines, Bytes int64 }{
+ {2, 12},
+ {1, 7}}
+ for i, stats := range []struct {
+ Lines, Bytes int64
+ }{infoStats, errorStats} {
+ if got, want := stats.Lines, expected[i].Lines; got != want {
+ t.Errorf("%d: got %v, want %v", i, got, want)
+ }
+ // Need to have written out at least as many bytes as the actual message.
+ if got, want := stats.Bytes, expected[i].Bytes; got <= want {
+ t.Errorf("%d: got %v, but not > %v", i, got, want)
+ }
+ }
+
+}
diff --git a/vlog/model.go b/vlog/model.go
deleted file mode 100644
index 8f8e75c..0000000
--- a/vlog/model.go
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright 2015 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package vlog
-
-import (
- // TODO(cnicolaou): remove this dependency in the future. For now this
- // saves us some code.
- "github.com/cosnicolaou/llog"
-)
-
-type InfoLog interface {
- // Info logs to the INFO log.
- // Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
- Info(args ...interface{})
-
- // Infoln logs to the INFO log.
- // Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
- Infof(format string, args ...interface{})
-
- // InfoDepth acts as Info but uses depth to determine which call frame to log.
- // A depth of 0 is equivalent to calling Info.
- InfoDepth(depth int, args ...interface{})
-
- // InfofDepth acts as Infof but uses depth to determine which call frame to log.
- // A depth of 0 is equivalent to calling Infof.
- InfofDepth(depth int, format string, args ...interface{})
-
- // InfoStack logs the current goroutine's stack if the all parameter
- // is false, or the stacks of all goroutines if it's true.
- InfoStack(all bool)
-}
-
-type Verbosity interface {
- // V returns true if the configured logging level is greater than or equal to its parameter
- V(level Level) bool
- // VI is like V, except that it returns an instance of the Info
- // interface that will either log (if level >= the configured level)
- // or discard its parameters. This allows for logger.VI(2).Info
- // style usage.
- VI(level Level) InfoLog
-}
-
-// Level specifies a level of verbosity for V logs.
-// It can be set via the Level optional parameter to Configure.
-// It implements the flag.Value interface to support command line option parsing.
-type Level llog.Level
-
-// Set is part of the flag.Value interface.
-func (l *Level) Set(v string) error {
- return (*llog.Level)(l).Set(v)
-}
-
-// Get is part of the flag.Value interface.
-func (l *Level) Get(v string) interface{} {
- return *l
-}
-
-// String is part of the flag.Value interface.
-func (l *Level) String() string {
- return (*llog.Level)(l).String()
-}
-
-// StderrThreshold identifies the sort of log: info, warning etc.
-// The values match the corresponding constants in C++ - e.g WARNING etc.
-// It can be set via the StderrThreshold optional parameter to Configure.
-// It implements the flag.Value interface to support command line option parsing.
-type StderrThreshold llog.Severity
-
-// Set is part of the flag.Value interface.
-func (s *StderrThreshold) Set(v string) error {
- return (*llog.Severity)(s).Set(v)
-}
-
-// Get is part of the flag.Value interface.
-func (s *StderrThreshold) Get(v string) interface{} {
- return *s
-}
-
-// String is part of the flag.Value interface.
-func (s *StderrThreshold) String() string {
- return (*llog.Severity)(s).String()
-}
-
-// ModuleSpec allows for the setting of specific log levels for specific
-// modules. The syntax is recordio=2,file=1,gfs*=3
-// It can be set via the ModuleSpec optional parameter to Configure.
-// It implements the flag.Value interface to support command line option parsing.
-type ModuleSpec struct {
- llog.ModuleSpec
-}
-
-// FilepathSpec allows for the setting of specific log levels for specific
-// files matched by a regular expression. The syntax is <re>=3,<re1>=2.
-// It can be set via the FilepathSpec optional parameter to Configure.
-// It implements the flag.Value interface to support command line option parsing.
-type FilepathSpec struct {
- llog.FilepathSpec
-}
-
-// TraceLocation specifies the location, file:N, which when encountered will
-// cause logging to emit a stack trace.
-// It can be set via the TraceLocation optional parameter to Configure.
-// It implements the flag.Value interface to support command line option parsing.
-type TraceLocation struct {
- llog.TraceLocation
-}
-
-// LevelStats tracks the number of lines of output and number of bytes
-// per severity level.
-type LevelStats llog.Stats
-
-type Logger interface {
- InfoLog
- Verbosity
-
- // Flush flushes all pending log I/O.
- FlushLog()
-
- // Error logs to the ERROR and INFO logs.
- // Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
- Error(args ...interface{})
-
- // ErrorDepth acts as Error but uses depth to determine which call frame to log.
- // A depth of 0 is equivalent to calling Error.
- ErrorDepth(depth int, args ...interface{})
-
- // Errorf logs to the ERROR and INFO logs.
- // Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
- Errorf(format string, args ...interface{})
-
- // Fatal logs to the FATAL, ERROR and INFO logs,
- // including a stack trace of all running goroutines, then calls os.Exit(255).
- // Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
- Fatal(args ...interface{})
-
- // FatalDepth acts as Fatal but uses depth to determine which call frame to log.
- // A depth of 0 is equivalent to calling Fatal.
- FatalDepth(depth int, args ...interface{})
-
- // Fatalf logs to the FATAL, ERROR and INFO logs,
- // including a stack trace of all running goroutines, then calls os.Exit(255).
- // Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
- Fatalf(format string, args ...interface{})
-
- // Panic is equivalent to Error() followed by a call to panic().
- Panic(args ...interface{})
-
- // PanicDepth acts as Panic but uses depth to determine which call frame to log.
- // A depth of 0 is equivalent to calling Panic.
- PanicDepth(depth int, args ...interface{})
-
- // Panicf is equivalent to Errorf() followed by a call to panic().
- Panicf(format string, args ...interface{})
-
- // Configure configures all future logging. Some options
- // may not be usable if Configure is called from an init function,
- // in which case an error will be returned. The Configured error is
- // returned if ConfigureLogger has already been called unless the
- // OverridePriorConfiguration options is included.
- // Some options only take effect if they are set before the logger
- // is used. Once anything is logged using the logger, these options
- // will silently be ignored. For example, LogDir, LogToStderr or
- // AlsoLogToStderr fall in this category.
- Configure(opts ...LoggingOpts) error
-
- // Stats returns stats on how many lines/bytes haven been written to
- // this set of logs per severity level.
- Stats() LevelStats
-
- // LogDir returns the currently configured directory for storing logs.
- LogDir() string
-}
diff --git a/vlog/util_test.go b/vlog/util_test.go
deleted file mode 100644
index 82f1415..0000000
--- a/vlog/util_test.go
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2015 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package vlog
-
-// SetLog allows us to override the Log global for testing purposes.
-func SetLog(l Logger) {
- Log = l.(*logger)
-}