Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[建議] logger增加debug level的功能 #29

Closed
tanyeun opened this issue Feb 2, 2021 · 4 comments · Fixed by #272
Closed

[建議] logger增加debug level的功能 #29

tanyeun opened this issue Feb 2, 2021 · 4 comments · Fixed by #272
Labels
enhancement New feature or request

Comments

@tanyeun
Copy link
Contributor

tanyeun commented Feb 2, 2021

原本作法的問題 / Existed Problem

目前所有的logger message都會直接print出來
Example
image

實作細節 / Details of Implement

@PichuChen 稍微討論過了一下,有兩種做法
一個是在main那邊加上可以吃command line option的架構
我個人是比較喜歡這種作法,因為很適合習慣用command line的開發者使用
而且彈性會比在config file裡面加參數來得彈性

初步想法是:

./Ptt-backend --logLevel debug
./Ptt-backend --logLevel Warning
... 分別對應
image
如果是設成
./Ptt-backend --logLevel Error
那麼只會印出:
logger.Errorf
logger.Criticalf
logger.Alertf
logger.Emergencyf

如果是設成
./Ptt-backend --logLevel Alert
那麼只會印出:
logger.Emergencyf

另一種做法是在config_default.toml裡面多加一個參數

應該屬於低難度適合新手的(比如我XDDD)
估計一個人一個周末一定可以弄出來

期程 / Schedule

相關文件 / Documents

@tanyeun tanyeun added the enhancement New feature or request label Feb 2, 2021
@rainlay
Copy link

rainlay commented Feb 3, 2021

可以加在類似環境變數檔案的地方如 config.toml, 也相應簡單直覺,

如果以後有不同的測試環境,可以於 ci/cd 或 env 設定不同的 log level。(當然在 go build 加入 flag 也是能達到相同效果)

@tanyeun
Copy link
Contributor Author

tanyeun commented Feb 4, 2021

相關討論 #21

@PichuChen
Copy link
Member

這個 ISSUE 目前還有在更新嗎? 不然兩週後要把他先關掉了喔?

@karta0807913
Copy link
Contributor

我在 #272 試著實做了一下這篇所說的內容,需要請各位幫我看一下是不是各位所期望的內容/行為

PichuChen added a commit that referenced this issue Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants