mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-20 07:04:08 +00:00
merge log into common log
This commit is contained in:
45 files changed
+297
-406
No files matched your search
@@ -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)}, " ")
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user