mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
comments
This commit is contained in:
parent
3938c65f7d
commit
7fdaa02bf6
@ -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…
Reference in New Issue
Block a user