mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-10 06:16:53 -05:00
refactor
This commit is contained in:
parent
7720d6bff6
commit
6626c22a8d
@ -22,7 +22,7 @@ type accessLogger interface {
|
|||||||
type noOpAccessLogger struct {
|
type noOpAccessLogger struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *noOpAccessLogger) Log(from, to string, status AccessStatus, reason string) {
|
func (this *noOpAccessLogger) Log(from, to string, status AccessStatus, reason string) {
|
||||||
// Swallow
|
// Swallow
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,8 +39,8 @@ type fileAccessLogger struct {
|
|||||||
file *os.File
|
file *os.File
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *fileAccessLogger) close() {
|
func (this *fileAccessLogger) close() {
|
||||||
logger.file.Close()
|
this.file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *fileAccessLogger) Log(from, to string, status AccessStatus, reason string) {
|
func (logger *fileAccessLogger) Log(from, to string, status AccessStatus, reason string) {
|
||||||
@ -56,9 +56,9 @@ func (logger *fileAccessLogger) Log(from, to string, status AccessStatus, reason
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *fileAccessLogger) Run() {
|
func (this *fileAccessLogger) Run() {
|
||||||
for entry := range logger.queue {
|
for entry := range this.queue {
|
||||||
logger.logger.Println(entry.From + " " + string(entry.Status) + " " + entry.To + " " + entry.Reason)
|
this.logger.Println(entry.From + " " + string(entry.Status) + " " + entry.To + " " + entry.Reason)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ type logger interface {
|
|||||||
type noOpLogger struct {
|
type noOpLogger struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *noOpLogger) WriteLog(prefix, format string, v ...interface{}) {
|
func (this *noOpLogger) WriteLog(prefix, format string, v ...interface{}) {
|
||||||
// Swallow
|
// Swallow
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,14 +30,14 @@ type streamLogger struct {
|
|||||||
writer io.Writer
|
writer io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *streamLogger) WriteLog(prefix, format string, v ...interface{}) {
|
func (this *streamLogger) WriteLog(prefix, format string, v ...interface{}) {
|
||||||
var data string
|
var data string
|
||||||
if v == nil || len(v) == 0 {
|
if v == nil || len(v) == 0 {
|
||||||
data = format
|
data = format
|
||||||
} else {
|
} else {
|
||||||
data = fmt.Sprintf(format, v...)
|
data = fmt.Sprintf(format, v...)
|
||||||
}
|
}
|
||||||
l.writer.Write([]byte(prefix + data + platform.LineSeparator()))
|
this.writer.Write([]byte(prefix + data + platform.LineSeparator()))
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user