v0.1 - initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package winpwn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Info/Success/Warn/Error are winpwn's leveled logger, the analogue of
|
||||
// pwntools' log.info/log.success/log.warn/log.error. All four write to
|
||||
// stderr (so they never interleave with a tube's own stdout traffic) and
|
||||
// are gated by Context.LogLevel -- set Context.LogLevel = LogLevelSilent to
|
||||
// quiet a script down for scripted/CI use.
|
||||
func Info(format string, args ...any) {
|
||||
logAt(LogLevelInfo, "[*]", format, args...)
|
||||
}
|
||||
|
||||
func Success(format string, args ...any) {
|
||||
logAt(LogLevelInfo, "[+]", format, args...)
|
||||
}
|
||||
|
||||
func Warn(format string, args ...any) {
|
||||
logAt(LogLevelWarn, "[!]", format, args...)
|
||||
}
|
||||
|
||||
func Error(format string, args ...any) {
|
||||
logAt(LogLevelError, "[-]", format, args...)
|
||||
}
|
||||
|
||||
func logAt(level LogLevel, prefix, format string, args ...any) {
|
||||
if level < Context.LogLevel {
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
fmt.Fprintf(os.Stderr, "%s %s %s\n", time.Now().Format("15:04:05"), prefix, msg)
|
||||
}
|
||||
Reference in New Issue
Block a user