mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 18:17:52 -05:00
fix log format
This commit is contained in:
parent
2b8cc43cb4
commit
3938c65f7d
@ -11,7 +11,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LogWriter interface {
|
type LogWriter interface {
|
||||||
io.WriteCloser
|
Write(string) error
|
||||||
|
io.Closer
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogWriterCreator func() LogWriter
|
type LogWriterCreator func() LogWriter
|
||||||
@ -44,13 +45,10 @@ func (l *generalLogger) run() {
|
|||||||
}
|
}
|
||||||
defer logger.Close()
|
defer logger.Close()
|
||||||
|
|
||||||
ls := []byte(platform.LineSeparator())
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case msg := <-l.buffer:
|
case msg := <-l.buffer:
|
||||||
logger.Write([]byte(msg.String()))
|
logger.Write(msg.String() + platform.LineSeparator())
|
||||||
logger.Write(ls)
|
|
||||||
dataWritten = true
|
dataWritten = true
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if !dataWritten {
|
if !dataWritten {
|
||||||
@ -78,9 +76,9 @@ type consoleLogWriter struct {
|
|||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *consoleLogWriter) Write(b []byte) (int, error) {
|
func (w *consoleLogWriter) Write(s string) error {
|
||||||
w.logger.Print(string(b))
|
w.logger.Print(s)
|
||||||
return len(b), nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *consoleLogWriter) Close() error {
|
func (w *consoleLogWriter) Close() error {
|
||||||
@ -92,9 +90,9 @@ type fileLogWriter struct {
|
|||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *fileLogWriter) Write(b []byte) (int, error) {
|
func (w *fileLogWriter) Write(s string) error {
|
||||||
w.logger.Print(string(b))
|
w.logger.Print(s)
|
||||||
return len(b), nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *fileLogWriter) Close() error {
|
func (w *fileLogWriter) Close() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user