1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

Revert "use default logger for android and ios"

This reverts commit 9743380e2d.
This commit is contained in:
Darien Raymond 2018-12-06 17:03:15 +01:00
parent 50e77cbb19
commit b9450d8475
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 2 additions and 31 deletions

View File

@ -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

View File

@ -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)