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

无法打印输出cron的全量日志 #68

Closed
ly-wjj opened this issue Oct 12, 2023 · 1 comment · Fixed by #69
Closed

无法打印输出cron的全量日志 #68

ly-wjj opened this issue Oct 12, 2023 · 1 comment · Fixed by #69
Assignees

Comments

@ly-wjj
Copy link

ly-wjj commented Oct 12, 2023

问题说明:
当设置的标准日志输出,在addFunc中的func想要日志输出,实际上并没有输出日志。设置WithPrintLogInfo只是打印了dcron的日志,cron的日志还是无法打印。
问题原因:
默认设置日志格式的时候

// WithLogger both set dcron and cron logger.
func WithLogger(logger interface{ Printf(string, ...interface{}) }) Option {
	return func(dcron *Dcron) {
		//set dcron logger
		dcron.logger = logger
		//set cron logger,这里设置的是标准日志输出,很多信息无法打印
		f := cron.WithLogger(cron.PrintfLogger(logger))
		dcron.crOptions = append(dcron.crOptions, f)
	}
}
// PrintfLogger wraps a Printf-based logger (such as the standard library "log")
// into an implementation of the Logger interface which logs errors only.
func PrintfLogger(l interface{ Printf(string, ...interface{}) }) Logger {
	return printfLogger{l, false}
}

// VerbosePrintfLogger wraps a Printf-based logger (such as the standard library
// "log") into an implementation of the Logger interface which logs everything.
func VerbosePrintfLogger(l interface{ Printf(string, ...interface{}) }) Logger {
	return printfLogger{l, true}
}

建议设置dcron.loginfo设置为true的时候,则cron改成,f := cron.VerbosePrintfLogger(cron.PrintfLogger(logger)) ?

@dxyinme
Copy link
Collaborator

dxyinme commented Oct 16, 2023

感谢提交issue, 会跟进这个问题。

@dxyinme dxyinme linked a pull request Oct 16, 2023 that will close this issue
@dxyinme dxyinme self-assigned this Oct 16, 2023
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 a pull request may close this issue.

2 participants