mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-17 23:06:30 -05:00
comments
This commit is contained in:
parent
3938c65f7d
commit
7fdaa02bf6
@ -10,11 +10,13 @@ import (
|
|||||||
"v2ray.com/core/common/signal"
|
"v2ray.com/core/common/signal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// LogWriter is the interface for writing logs.
|
||||||
type LogWriter interface {
|
type LogWriter interface {
|
||||||
Write(string) error
|
Write(string) error
|
||||||
io.Closer
|
io.Closer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LogWriterCreator is a function to create LogWriters.
|
||||||
type LogWriterCreator func() LogWriter
|
type LogWriterCreator func() LogWriter
|
||||||
|
|
||||||
type generalLogger struct {
|
type generalLogger struct {
|
||||||
@ -99,6 +101,7 @@ func (w *fileLogWriter) Close() error {
|
|||||||
return w.file.Close()
|
return w.file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateStdoutLogWriter returns a LogWriterCreator that creates LogWriter for stdout.
|
||||||
func CreateStdoutLogWriter() LogWriterCreator {
|
func CreateStdoutLogWriter() LogWriterCreator {
|
||||||
return func() LogWriter {
|
return func() LogWriter {
|
||||||
return &consoleLogWriter{
|
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) {
|
func CreateFileLogWriter(path string) (LogWriterCreator, 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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user