Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

implemented logger in d2gamescreen #925

Merged
merged 16 commits into from
Nov 18, 2020

Conversation

gucio321
Copy link
Contributor

Hi there,
no more import "log" in module d2gamescreen

d2app/app.go Outdated Show resolved Hide resolved
Copy link
Contributor

@gravestench gravestench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont use the default log level, pass the LogLevel in from App.Config.LogLevel when you create the screens.

gravestench
gravestench previously approved these changes Nov 15, 2020
@gucio321
Copy link
Contributor Author

I've added logger to d2game/d2player
sory for lints, I'll fix it tomorrow :-)

@gucio321
Copy link
Contributor Author

Ok, I think, this is complete

Comment on lines +99 to +102
gw.logger = d2util.NewLogger()
gw.logger.SetLevel(l)
gw.logger.SetPrefix(logPrefix)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is problematic. Do individual widgets need logger instances?

should we not instead return these errors to the HUD and let the HUD report errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we can return errors to HUD, but ONLY ERRORS. What about logger.Info like in help_overlay:go:202?

Comment on lines +49 to +56
type skillIcon struct {
*d2ui.BaseWidget
lvlLabel *d2ui.Label
sprite *d2ui.Sprite
skill *d2hero.HeroSkill

logger *d2util.Logger
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another widget that has it's own logger. maybe this is not such an issue if you assign to it an existing logger (like from the HUD or some menu)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, so could you give some example. what should I type instead of logger *d2util.Logger?

Copy link
Contributor

@gravestench gravestench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that widgets should create loggers, they should likely use a parent logger instance (like the UI Manager logger instance).

@essial thoughts?

@gravestench gravestench dismissed their stale review November 16, 2020 19:12

Questionable logger instances in widgets

@gravestench
Copy link
Contributor

After a lot of discussion with @gucio321, it's not so bad if widgets have loggers. An alternate approach of using the logger of whatever was using the widget was considered, but was more trouble than it was worth. If there are no objections I would like to merge.

@gravestench gravestench merged commit 2153f5c into OpenDiablo2:master Nov 18, 2020
gucio321 pushed a commit to gucio321/OpenDiablo2 that referenced this pull request Nov 19, 2020
gravestench pushed a commit that referenced this pull request Nov 21, 2020
* logger for d2audio & d2map

* logger for d2ui e.t.c

* d2inventory now passes on error messages

* no more importing log in d2core

* implemented #925

* added logger to part of d2networking & fixed "need to be changed" comments

* fixed lints

* fixed errors

Co-authored-by: M. Sz <mszeptuch@protonmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants