-
Notifications
You must be signed in to change notification settings - Fork 228
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
add log filename and line number #252
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,6 +26,7 @@ import ( | |||||||||||
// to ensure that exec-entrypoint and run can make use of them. | ||||||||||||
_ "k8s.io/client-go/plugin/pkg/client/auth" | ||||||||||||
|
||||||||||||
zaplog "go.uber.org/zap" | ||||||||||||
"go.uber.org/zap/zapcore" | ||||||||||||
schedulingv1 "k8s.io/api/scheduling/v1" | ||||||||||||
"k8s.io/apimachinery/pkg/runtime" | ||||||||||||
|
@@ -70,6 +71,7 @@ func main() { | |||||||||||
|
||||||||||||
opts := zap.Options{ | ||||||||||||
TimeEncoder: zapcore.RFC3339NanoTimeEncoder, | ||||||||||||
ZapOpts: []zaplog.Option{zaplog.AddCaller(), zaplog.AddCallerSkip(-1)}, | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the skip for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we cannot get the right There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about other log lines? For example, the ones coming from the scheduler. I'm wondering if controller-runtime is increasing the Skip somewhere just when calling Reconcile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the controller-runtime will add 1 Skip in controller-runtime/pkg/log/zap/zap.go. Maybe we should descrease 1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logs in scheduler.go: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are those logs with the If so, then I'm fine leaving it and then we can remove it once kubernetes-sigs/controller-runtime#1737 is fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These logs are not added by me. Line number was not correct because I pushed these code based on the old commit(e5fdd9b) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me restate the question: Do the logs for scheduler.go file look accurate when using the code in this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. kueue/pkg/scheduler/scheduler.go Lines 303 to 307 in e5fdd9b
|
||||||||||||
} | ||||||||||||
opts.BindFlags(flag.CommandLine) | ||||||||||||
flag.Parse() | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import ( | |
|
||
"github.com/onsi/ginkgo/v2" | ||
"github.com/onsi/gomega" | ||
zaplog "go.uber.org/zap" | ||
"go.uber.org/zap/zapcore" | ||
batchv1 "k8s.io/api/batch/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
|
@@ -58,10 +59,16 @@ type Framework struct { | |
} | ||
|
||
func (f *Framework) Setup() (context.Context, *rest.Config, client.Client) { | ||
logTimeEncodeOpt := func(o *zap.Options) { | ||
o.TimeEncoder = zapcore.RFC3339NanoTimeEncoder | ||
opts := zap.Options{ | ||
TimeEncoder: zapcore.RFC3339NanoTimeEncoder, | ||
ZapOpts: []zaplog.Option{zaplog.AddCaller(), zaplog.AddCallerSkip(-1)}, | ||
} | ||
ctrl.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(zapcore.Level(-3)), logTimeEncodeOpt)) | ||
ctrl.SetLogger(zap.New( | ||
zap.WriteTo(ginkgo.GinkgoWriter), | ||
zap.UseDevMode(true), | ||
zap.Level(zapcore.Level(-3)), | ||
zap.UseFlagOptions(&opts)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably overriding the level above, @kerthcet. We should set the options as a function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks aldo, I'll have a test then. |
||
) | ||
|
||
ginkgo.By("bootstrapping test environment") | ||
f.testEnv = &envtest.Environment{ | ||
|
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.
just zap
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 have imported
"sigs.k8s.io/controller-runtime/pkg/log/zap"
before.