Browse Source

comments

pull/861/head
Darien Raymond 7 years ago
parent
commit
7fdaa02bf6
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 4
      common/log/logger.go

4
common/log/logger.go

@ -10,11 +10,13 @@ import (
"v2ray.com/core/common/signal"
)
// LogWriter is the interface for writing logs.
type LogWriter interface {
Write(string) error
io.Closer
}
// LogWriterCreator is a function to create LogWriters.
type LogWriterCreator func() LogWriter
type generalLogger struct {
@ -99,6 +101,7 @@ func (w *fileLogWriter) Close() error {
return w.file.Close()
}
// CreateStdoutLogWriter returns a LogWriterCreator that creates LogWriter for stdout.
func CreateStdoutLogWriter() LogWriterCreator {
return func() LogWriter {
return &consoleLogWriter{
@ -107,6 +110,7 @@ func CreateStdoutLogWriter() LogWriterCreator {
}
}
// CreateFileLogWriter returns a LogWriterCreator that creates LogWriter for the given file.
func CreateFileLogWriter(path string) (LogWriterCreator, error) {
file, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {

Loading…
Cancel
Save