-
Notifications
You must be signed in to change notification settings - Fork 10
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
chore: Consistent/Improved logging #152
Conversation
Removes the use of logrus in all external-dns code in favour of setting a `logr.Logger` on all structs. Constructors are used throughout to create new instances of components (plan, registry and providers), with each requiring the current context and a logger instance retrieved from it with an appropriate logger name added where required.
@@ -156,7 +157,7 @@ func (r *ManagedZoneReconciler) Reconcile(ctx context.Context, req ctrl.Request) | |||
if err != nil { | |||
return ctrl.Result{}, err | |||
} | |||
log.Log.Info("Reconciled ManagedZone", "managedZone", managedZone.Name) | |||
logger.Info("Reconciled ManagedZone") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we need the managedzone name here, but we do need it in some of the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't, will update those to remove the duplicate key/values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should all be updated now to remove adding the details of the current resource at individual log statements. That is already being done as part of the logger setup in Reconcile
. Further improvements to the logging and what metadata is included and where will be done as part of #118
Construct logger in Reconcile function (DNSRecord and ManagedZone), naming each appropriately, and ensure it is used by all logging statements throughout the call stack for the request. Initialise external-dns components (registry, plan and providers) using correct context to ensure the appropriate logger is used internally. Removes all references to logrus logger.
c4d27a9
to
3dbf24f
Compare
return false, nil | ||
} | ||
return false, err | ||
} | ||
logger.Info("Deleted DNSRecord in manage zone", "dnsRecord", dnsRecord.Name, "managedZone", managedZone.Name) | ||
logger.Info("Deleted DNSRecord in manage zone", "managedZone", managedZone.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example:
{
"level": "info",
"ts": "2024-06-04T16:32:37+01:00",
"logger": "dnsrecord_controller",
"msg": "Deleted DNSRecord in manage zone",
"controller": "dnsrecord",
"controllerGroup": "kuadrant.io",
"controllerKind": "DNSRecord",
"DNSRecord": {
"name": "t-single-lively-waterfall",
"namespace": "dnstest"
},
"namespace": "dnstest",
"name": "t-single-lively-waterfall",
"reconcileID": "81a1838b-c782-4323-8baf-58486cadbcec",
"managedZone": "dev-mz-aws"
}
Left managedZone
here for now although i expect that will be moved and set on the context higher up the stack as part of #117
closes #124
external-dns: Remove logrus logger
Removes the use of logrus in all external-dns code in favour of setting a
logr.Logger
on all objects.Constructors are used throughout to create new instances of components (plan, registry and providers), with each requiring the current context, retrieving a logger instance from it with an appropriate logger name added where required.
chore: Consistent/Improved logging
Construct logger in
Reconcile
functions (DNSRecord and ManagedZone), naming each appropriately, and ensure it is used by all logging statements throughout the call stack for the request.Initialise external-dns components (registry, plan and providers) using correct context to ensure the appropriate logger is used internally. Removes all references to logrus logger.