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

gas price oracle to use logger #10304

Merged
merged 6 commits into from
May 22, 2024
Merged

gas price oracle to use logger #10304

merged 6 commits into from
May 22, 2024

Conversation

AskAlexSharov
Copy link
Collaborator

No description provided.

@@ -133,7 +133,7 @@ func (api *APIImpl) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, err
return nil, err
}
defer tx.Rollback()
oracle := gasprice.NewOracle(NewGasPriceOracleBackend(tx, api.BaseAPI), ethconfig.Defaults.GPO, api.gasCache)
oracle := gasprice.NewOracle(NewGasPriceOracleBackend(tx, api.BaseAPI), ethconfig.Defaults.GPO, api.gasCache, api.logger.New("app", "gasPriceOracle"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for an update.

I suggest a convention to have this call inside the constructor: pass a parentLogger, and call parentLogger.New("app", "gasPriceOracle") inside NewOracle. This way all instances will get this tag. If the class gets renamed, only one string needs to be updated.

P.S. I see that some places use log.New("t8ntool") (1 parameter) and some use log.New("app", "caplin") (2 parameters). What's the difference? Is the "app" key a special "default" key that is going to be formatted on the left? and all other keys are going as k1=v1,k2=v2... on the right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

func TestName(t *testing.T) {
	log.New("a", "b").Error("message", "d", "e")
	log.New("a").Error("c", "d", "e")
	t.Fail()
}

[EROR] [05-14|15:21:28.867] message                                  a=b d=e
[EROR] [05-14|15:21:28.868] c                                        a=nil LOG15_ERROR="Normalized odd number of arguments by adding nil" d=e

current logger expecting even amount of arguments (key/value pairs). I guess log.New("t8ntool") is bad. so, better pass 2 args.

Copy link
Collaborator

Choose a reason for hiding this comment

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

func TestName(t *testing.T) {
	log.New("a", "b").Error("message", "d", "e")
	log.New("a").Error("c", "d", "e")
	t.Fail()
}

[EROR] [05-14|15:21:28.867] message                                  a=b d=e
[EROR] [05-14|15:21:28.868] c                                        a=nil LOG15_ERROR="Normalized odd number of arguments by adding nil" d=e

current logger expecting even amount of arguments (key/value pairs). I guess log.New("t8ntool") is bad. so, better pass 2 args.

I see. So if we want to have a message prefix like [gasPriceOracle] after the date, we would need to extend the logger API to support this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe... i only don't know - if can make it lazy (no sprintf if logLevel is lower).

@awskii awskii merged commit 1bca982 into main May 22, 2024
8 checks passed
@awskii awskii deleted the gas_price_oracle_log branch May 22, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants