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

4
.gitignore vendored
View File

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

View File

@ -2,4 +2,17 @@
# 1只刷文章何视频
# 2只刷文章和视频和每日答题
# 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,
HandleSIGINT: nil,
HandleSIGTERM: nil,
Headless: playwright.Bool(c.ShowBrowser),
Headless: playwright.Bool(!c.ShowBrowser),
Proxy: nil,
SlowMo: nil,
Timeout: nil,

View File

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