@@ -35,6 +35,7 @@ type App struct {
3535 db * bolt.DB
3636 connects sync.Map
3737 logger * Logger
38+ debug bool
3839}
3940
4041// NewApp creates a new App application struct
@@ -61,6 +62,12 @@ func NewApp() *App {
6162// so we can call the runtime methods
6263func (app * App ) startup (ctx context.Context ) {
6364 app .ctx = ctx
65+ setting , err := app .GetSetting ()
66+ if err != nil {
67+ app .logger .Error ("get setting failed" , "reason" , err )
68+ } else {
69+ app .debug = setting .Debug
70+ }
6471}
6572
6673func (app * App ) shutdown (ctx context.Context ) {
@@ -177,6 +184,7 @@ func (app *App) GetConnect(name string) (*ConnectConfig, error) {
177184}
178185
179186func (app * App ) UpdateSetting (settings * AppSetting ) error {
187+ app .debug = settings .Debug
180188 data , err := json .Marshal (settings )
181189 if err != nil {
182190 app .logger .Error ("update settings failed" , "reason" , err )
@@ -218,6 +226,9 @@ func (app *App) DialConnect(name string) ([]string, error) {
218226 app .logger .Error ("dial connect failed: find connect config failed" , "reason" , err )
219227 return nil , err
220228 }
229+ if app .debug {
230+ cc .debug = true
231+ }
221232 httpClient , err := NewHttpClient (cc )
222233 if err != nil {
223234 app .logger .Error ("dial connect failed: create http client failed" , "reason" , err )
0 commit comments