mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-13 14:44:15 +00:00
Refactor vmess internal struct for better readability
This commit is contained in:
1 parent
8a6b07ba61
commit
791ac780f0
7 files changed
+147
-229
No files matched your search
+45
@@ -0,0 +1,45 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
const (
|
||||
DebugLevel = LogLevel(0)
|
||||
InfoLevel = LogLevel(1)
|
||||
WarningLevel = LogLevel(2)
|
||||
ErrorLevel = LogLevel(3)
|
||||
)
|
||||
|
||||
var logLevel = WarningLevel
|
||||
|
||||
type LogLevel int
|
||||
|
||||
func SetLogLevel(level LogLevel) {
|
||||
logLevel = level
|
||||
}
|
||||
|
||||
func writeLog(data string, level LogLevel) {
|
||||
if level < logLevel {
|
||||
return
|
||||
}
|
||||
log.Print(data)
|
||||
}
|
||||
|
||||
func Info(format string, v ...interface{}) {
|
||||
data := fmt.Sprintf(format, v)
|
||||
writeLog("[Info]"+data, InfoLevel)
|
||||
}
|
||||
|
||||
func Warning(format string, v ...interface{}) {
|
||||
data := fmt.Sprintf(format, v)
|
||||
writeLog("[Warning]"+data, WarningLevel)
|
||||
}
|
||||
|
||||
func Error(format string, v ...interface{}) error {
|
||||
data := fmt.Sprintf(format, v)
|
||||
writeLog("[Error]"+data, ErrorLevel)
|
||||
return errors.New(data)
|
||||
}
|
||||
Reference in new issue
Block a user