feat: 添加日志记录功能,添加浏览器隐藏功能

This commit is contained in:
johlanse 2021-11-15 21:52:59 +08:00
parent 48b91c0316
commit b25e1930d6
4 changed files with 23 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.exe *.exe
.idea/ .idea/
*.png *.png
/logs/
*.log

View File

@ -3,3 +3,16 @@
# 2只刷文章和视频和每日答题 # 2只刷文章和视频和每日答题
# 3刷文章和视频和每日答题每周答题和专项答题 # 3刷文章和视频和每日答题每周答题和专项答题
model: 1 model: 1
# 日志等级
# panic
# fatal
# error
# warn, warning
# info
# debug
# trace
log_level: "info"
# 是否显示浏览器
show_browser: false

View File

@ -63,7 +63,7 @@ func (c *Core) Init() {
HandleSIGHUP: nil, HandleSIGHUP: nil,
HandleSIGINT: nil, HandleSIGINT: nil,
HandleSIGTERM: nil, HandleSIGTERM: nil,
Headless: playwright.Bool(c.ShowBrowser), Headless: playwright.Bool(!c.ShowBrowser),
Proxy: nil, Proxy: nil,
SlowMo: nil, SlowMo: nil,
Timeout: nil, Timeout: nil,

View File

@ -1,6 +1,8 @@
package main package main
import ( import (
"fmt"
"io"
"os" "os"
"path" "path"
"time" "time"
@ -23,11 +25,12 @@ func init() {
log.Errorf("rotates init err: %v", err) log.Errorf("rotates init err: %v", err)
panic(err) panic(err)
} }
log.SetOutput(w) log.SetOutput(io.MultiWriter(w, os.Stdout))
log.SetFormatter(logFormatter) log.SetFormatter(logFormatter)
level, err := log.ParseLevel(config.LogLevel) level, err := log.ParseLevel(config.LogLevel)
log.SetLevel(level) log.SetLevel(level)
log.Info(config)
} }
var ( var (
@ -55,6 +58,7 @@ func main() {
if err != nil { if err != nil {
return return
} }
fmt.Println(config)
core.LearnArticle(login) core.LearnArticle(login)
core.LearnVideo(login) core.LearnVideo(login)