1
0
mirror of https://github.com/sairson/Yasso.git synced 2026-11-06 07:27:41 +08:00

Yasso更新大改动,更新扫描方式,去除不常用功能,增加指纹和协议识别,修补bug等

This commit is contained in:
sairson
2022-05-29 09:11:07 +08:00
parent a6cd80f8e8
commit cb72f18edd
129 changed files with 16619 additions and 6278 deletions

107
pkg/grdp/glog/log.go Normal file
View File

@@ -0,0 +1,107 @@
package glog
import (
"fmt"
"log"
"sync"
)
func init() {
}
var (
logger *log.Logger
level LEVEL
mu sync.Mutex
)
type LEVEL int
const (
DEBUG LEVEL = iota
INFO
WARN
ERROR
NONE
)
func SetLogger(l *log.Logger) {
l.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
logger = l
}
func SetLevel(l LEVEL) {
level = l
}
func checkLogger() {
if logger == nil && level != NONE {
panic("logger not inited")
}
}
func Debug(v ...interface{}) {
checkLogger()
if level <= DEBUG {
mu.Lock()
defer mu.Unlock()
logger.SetPrefix("[DEBUG]")
logger.Output(2, fmt.Sprintln(v...))
}
}
func Debugf(f string, v ...interface{}) {
checkLogger()
if level <= DEBUG {
mu.Lock()
defer mu.Unlock()
logger.SetPrefix("[DEBUG]")
logger.Output(2, fmt.Sprintln(fmt.Sprintf(f, v...)))
}
}
func Info(v ...interface{}) {
checkLogger()
if level <= INFO {
mu.Lock()
defer mu.Unlock()
logger.SetPrefix("[INFO]")
logger.Output(2, fmt.Sprintln(v...))
}
}
func Infof(f string, v ...interface{}) {
checkLogger()
if level <= INFO {
mu.Lock()
defer mu.Unlock()
logger.SetPrefix("[INFO]")
logger.Output(2, fmt.Sprintln(fmt.Sprintf(f, v...)))
}
}
func Warn(v ...interface{}) {
checkLogger()
if level <= WARN {
mu.Lock()
defer mu.Unlock()
logger.SetPrefix("[WARN]")
logger.Output(2, fmt.Sprintln(v...))
}
}
func Error(v ...interface{}) {
checkLogger()
if level <= ERROR {
mu.Lock()
defer mu.Unlock()
logger.SetPrefix("[ERROR]")
logger.Output(2, fmt.Sprintln(v...))
}
}
func Errorf(f string, v ...interface{}) {
checkLogger()
if level <= ERROR {
mu.Lock()
defer mu.Unlock()
logger.SetPrefix("[ERROR]")
logger.Output(2, fmt.Sprintln(fmt.Sprintf(f, v...)))
}
}