diff --git a/common/log/log.go b/common/log/log.go index 0c7b3160a..0cff1a06c 100644 --- a/common/log/log.go +++ b/common/log/log.go @@ -4,6 +4,8 @@ import ( "fmt" "io" "os" + + "github.com/v2ray/v2ray-core/common/platform" ) const ( @@ -35,8 +37,7 @@ func (l *streamLogger) WriteLog(prefix, format string, v ...interface{}) { } else { data = fmt.Sprintf(format, v...) } - l.writer.Write([]byte(prefix + data)) - l.writer.Write([]byte{'\n'}) + l.writer.Write([]byte(prefix + data + platform.LineSeparator())) } var ( diff --git a/common/platform/others.go b/common/platform/others.go index a0d25a5e4..0bd7ee77d 100644 --- a/common/platform/others.go +++ b/common/platform/others.go @@ -6,11 +6,10 @@ import ( "os" ) -type otherPlatformEnvironment struct { -} - -var environmentInstance = &otherPlatformEnvironment{} - -func (e *otherPlatformEnvironment) ExpandEnv(s string) string { +func ExpandEnv(s string) string { return os.ExpandEnv(s) } + +func LineSeparator() string { + return "\n" +} diff --git a/common/platform/platform.go b/common/platform/platform.go deleted file mode 100644 index a35f0fc4b..000000000 --- a/common/platform/platform.go +++ /dev/null @@ -1,10 +0,0 @@ -// Package platform provides platform specific functionalities. -package platform - -type environment interface { - ExpandEnv(s string) string -} - -func ExpandEnv(s string) string { - return environmentInstance.ExpandEnv(s) -} diff --git a/common/platform/windows.go b/common/platform/windows.go index 4a6ae7b82..7fc1f90d7 100644 --- a/common/platform/windows.go +++ b/common/platform/windows.go @@ -2,16 +2,11 @@ package platform -import ( - "os" -) - -type windowsEnvironment struct { -} - -var environmentInstance = &windowsEnvironment{} - -func (e *windowsEnvironment) ExpandEnv(s string) string { +func ExpandEnv(s string) string { // TODO return s } + +func LineSeparator() string { + return "\r\n" +}