diff --git a/app/log/log.go b/app/log/log.go index e3e53553..93f3fa96 100644 --- a/app/log/log.go +++ b/app/log/log.go @@ -4,7 +4,6 @@ package log import ( "context" - "runtime" "sync" "v2ray.com/core/common" @@ -31,18 +30,6 @@ func New(ctx context.Context, config *Config) (*Instance, error) { return g, nil } -func isMobile() bool { - return runtime.GOOS == "android" || (runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64")) -} - -func createStdLogWriter() log.WriterCreator { - if isMobile() { - return log.CreateDefaultLogWriter() - } - - return log.CreateStdoutLogWriter() -} - func (g *Instance) initAccessLogger() error { switch g.config.AccessLogType { case LogType_File: @@ -52,7 +39,7 @@ func (g *Instance) initAccessLogger() error { } g.accessLogger = log.NewLogger(creator) case LogType_Console: - g.accessLogger = log.NewLogger(createStdLogWriter()) + g.accessLogger = log.NewLogger(log.CreateStdoutLogWriter()) default: } return nil @@ -67,7 +54,7 @@ func (g *Instance) initErrorLogger() error { } g.errorLogger = log.NewLogger(creator) case LogType_Console: - g.errorLogger = log.NewLogger(createStdLogWriter()) + g.errorLogger = log.NewLogger(log.CreateStdoutLogWriter()) default: } return nil diff --git a/common/log/logger.go b/common/log/logger.go index a88b7b66..9a2591cb 100644 --- a/common/log/logger.go +++ b/common/log/logger.go @@ -119,22 +119,6 @@ func CreateStdoutLogWriter() WriterCreator { } } -type defaultLogWriter struct{} - -func (defaultLogWriter) Write(b []byte) (int, error) { - log.Print(string(b)) - return len(b), nil -} - -// CreateDefaultLogWriter returns a LogWriterCreator that creates LogWriter to write to default Golang logger. -func CreateDefaultLogWriter() WriterCreator { - return func() Writer { - return &consoleLogWriter{ - logger: log.New(defaultLogWriter{}, "", log.Ldate|log.Ltime), - } - } -} - // CreateFileLogWriter returns a LogWriterCreator that creates LogWriter for the given file. func CreateFileLogWriter(path string) (WriterCreator, error) { file, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)