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 helper function print_debug for debug purposes #928

Merged
merged 5 commits into from
Aug 31, 2021

Conversation

yabeow
Copy link
Contributor

@yabeow yabeow commented Aug 12, 2021

Hi there,

I've added an helper function called print_debug in DSL. This function will help to print DSL variables / outputs to stdout using fmt.Println function for debug purposes.

Note: I've tried to use your gologger package but it always requires a format string so I used the standard fmt package instead.

@ehsandeep ehsandeep changed the base branch from master to dev August 12, 2021 18:41
@@ -245,6 +245,11 @@ var functions = map[string]govaluate.ExpressionFunction{
data := deserialization.GenerateJavaGadget(gadget, cmd, encoding)
return data, nil
},
// for debug purposes
"print_stdout": func(args ...interface{}) (interface{}, error) {
fmt.Println(args)
Copy link
Member

Choose a reason for hiding this comment

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

We should add a message before printing the debug values, stating they are from print_debug function. Something like this @yabeow

	gologger.Info().Msgf("print_stdout debug value: ")
        fmt.Println(args)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice suggestion! I've added this, please check again 👍

@yabeow yabeow changed the title Add helper function print_stdout for debug purposes Add helper function print_debug for debug purposes Aug 23, 2021
@forgedhallpass
Copy link
Contributor

lgtm!

@ehsandeep ehsandeep merged commit 5525b0f into projectdiscovery:dev Aug 31, 2021
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

4 participants