merge log into common log

This commit is contained in:
Darien Raymond committed 2017-12-19 21:28:12 +01:00
1 parent 054ceb865d
commit f4c35db968
45 files changed
+297 -406

No files matched your search

-32
View File
@@ -1,32 +0,0 @@
package internal
import (
"fmt"
"strings"
"v2ray.com/core/common/serial"
)
type LogEntry interface {
fmt.Stringer
}
type ErrorLog struct {
Prefix string
Error error
}
func (l *ErrorLog) String() string {
return l.Prefix + l.Error.Error()
}
type AccessLog struct {
From interface{}
To interface{}
Status string
Reason interface{}
}
func (l *AccessLog) String() string {
return strings.Join([]string{serial.ToString(l.From), l.Status, serial.ToString(l.To), serial.ToString(l.Reason)}, " ")
}
-25
View File
@@ -1,25 +0,0 @@
package internal_test
import (
"testing"
. "v2ray.com/core/app/log/internal"
. "v2ray.com/ext/assert"
)
func TestAccessLog(t *testing.T) {
assert := With(t)
entry := &AccessLog{
From: "test_from",
To: "test_to",
Status: "Accepted",
Reason: "test_reason",
}
entryStr := entry.String()
assert(entryStr, HasSubstring, "test_from")
assert(entryStr, HasSubstring, "test_to")
assert(entryStr, HasSubstring, "test_reason")
assert(entryStr, HasSubstring, "Accepted")
}
+4 -7
View File
@@ -8,18 +8,15 @@ import (
"v2ray.com/core/common/platform"
)
type LogEntry interface {
String() string
}
type LogWriter interface {
Log(LogEntry)
Close()
}
type NoOpLogWriter struct {
}
func (*NoOpLogWriter) Log(entry LogEntry) {}
func (*NoOpLogWriter) Close() {}
type StdOutLogWriter struct {
logger *log.Logger
}