1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 23:47:07 -05:00

fix lint warnings

This commit is contained in:
Darien Raymond 2017-12-22 10:44:13 +01:00
parent 7fdaa02bf6
commit 4656d5fd6d
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -10,23 +10,23 @@ import (
"v2ray.com/core/common/signal" "v2ray.com/core/common/signal"
) )
// LogWriter is the interface for writing logs. // Writer is the interface for writing logs.
type LogWriter interface { type Writer interface {
Write(string) error Write(string) error
io.Closer io.Closer
} }
// LogWriterCreator is a function to create LogWriters. // WriterCreator is a function to create LogWriters.
type LogWriterCreator func() LogWriter type WriterCreator func() Writer
type generalLogger struct { type generalLogger struct {
creator LogWriterCreator creator WriterCreator
buffer chan Message buffer chan Message
access *signal.Semaphore access *signal.Semaphore
} }
// NewLogger returns a generic log handler that can handle all type of messages. // NewLogger returns a generic log handler that can handle all type of messages.
func NewLogger(logWriterCreator LogWriterCreator) Handler { func NewLogger(logWriterCreator WriterCreator) Handler {
return &generalLogger{ return &generalLogger{
creator: logWriterCreator, creator: logWriterCreator,
buffer: make(chan Message, 16), buffer: make(chan Message, 16),
@ -102,8 +102,8 @@ func (w *fileLogWriter) Close() error {
} }
// CreateStdoutLogWriter returns a LogWriterCreator that creates LogWriter for stdout. // CreateStdoutLogWriter returns a LogWriterCreator that creates LogWriter for stdout.
func CreateStdoutLogWriter() LogWriterCreator { func CreateStdoutLogWriter() WriterCreator {
return func() LogWriter { return func() Writer {
return &consoleLogWriter{ return &consoleLogWriter{
logger: log.New(os.Stdout, "", log.Ldate|log.Ltime), logger: log.New(os.Stdout, "", log.Ldate|log.Ltime),
} }
@ -111,13 +111,13 @@ func CreateStdoutLogWriter() LogWriterCreator {
} }
// CreateFileLogWriter returns a LogWriterCreator that creates LogWriter for the given file. // CreateFileLogWriter returns a LogWriterCreator that creates LogWriter for the given file.
func CreateFileLogWriter(path string) (LogWriterCreator, error) { func CreateFileLogWriter(path string) (WriterCreator, error) {
file, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) file, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil { if err != nil {
return nil, err return nil, err
} }
file.Close() file.Close()
return func() LogWriter { return func() Writer {
file, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) file, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil { if err != nil {
return nil return nil