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

✨ add rule progress logs #796

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zhoufenqin
Copy link
Contributor

As this issue in kantra, it's better to show to log processing in the console so user can know how many rules has been processed.
we can specify the log with "process-rule" name so that the kantra CLI can use log hook to select logs print in console.
related PR in kantra: konveyor/kantra#453

Signed-off-by: zhoufenqin <[email protected]>
@shawn-hurley
Copy link
Contributor

So there is one big problem that is not readily apparent:

The engine can't put things directly onto stdout because that would cause problems for other use-cases (kai_analyzer_rpc specifically). Because of this, I am worried about this change.

If we want logs to go to stdout, we could update here to also have a stdout logger. This will include all the logs for the given verbosity to Kantra, which could be a lot of information.

If we could do that, and see if the log output would be sufficient, then we can do that.

If that won't be because then the logs get too verbose, we could have an engine option for that accepts a "stdout" logger, (just another logr interface, then use that logger in the same location. If the option is not passed the engine will just default that to an empty logr that doesn't print anything.

What are your thoughts?

@zhoufenqin
Copy link
Contributor Author

@shawn-hurley Thank you for your explain, I didn't choose to update the log to stdout instand of anslysis.log file becuase the log is too verbose.

The engine can't put things directly onto stdout because that would cause problems for other use-cases (kai_analyzer_rpc specifically)

For this reason, I don't have more context, can you explain more about it or is there any record issue before?
Besides, I don't use the engion to directly put the log onto stdout, I still put the log to the path configured by the logger, then use log hook to print the log into the stdout in kantra repo, do you mean this kind of opeation may cause problems for other use-cases (kai_analyzer_rpc specifically)

we could have an engine option for that accepts a "stdout" logger

Yes, if you can, it's better, let me understand the step:

  1. accept the stdout logger
type ruleEngine struct {
	// Buffered channel where Rule Processors are watching
	ruleProcessing chan ruleMessage
	cancelFunc     context.CancelFunc
	logger         logr.Logger
        **consoleLogger  logr.Logger**  // Add a logger here

	wg *sync.WaitGroup

	incidentLimit    int
	codeSnipLimit    int
	contextLines     int
	incidentSelector string
	locationPrefixes []string
}
  1. log the rule processing in the same location.

Add the rule processing log in processRule function, then there is no need to use log hook in kantra

consoleLogger.WithName("process-rule").Info("processing rule", "ruleID", rule.RuleID) 

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.

2 participants