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

DHFPROD-1795: Debug class #1859

Merged
merged 1 commit into from
Feb 11, 2019
Merged

DHFPROD-1795: Debug class #1859

merged 1 commit into from
Feb 11, 2019

Conversation

clockworked247
Copy link
Contributor

Debug class

My implementation is generic, by design.

After instantiating a new Debug object with config, a simple JSON object
payload can be passed to the send() function. If that object's "type"
property is allowed by the current log level, then the output tagged
with metadata and the complete JSON object is passed as a string to
xdmp.log()

A payload type value that is not of an accepted type is rejected.
A payload type value that requires a higher log level than currently specified is rejected.

All rejected payloads return an Error object with message:
"Error: Log level "{this.logLevel}" does not have permission to log type: {payload type}"

If we want, we can add payload validation, ensuring that the payload type has the proper
parameters (ie. type "error" could require a "stack" property in the payload object)

After instantiating a new Debug object with config, a simple JSON object
payload can be passed to the send() function.  If that object's "type"
property is allowed by the current log level, then the output tagged
with metadata and the complete JSON object is passed as a string to
xdmp.log()

A payload type value that is not of an accepted type is rejected.
A payload type value that requires a higher log level than currently specified is rejected.

All rejected payloads return an Error object with message:
"Error: Log level "{this.logLevel}" does not have permission to log type: {payload type}"

If we want, we can add payload validation, ensuring that the payload type has the proper
parameters (ie. error should required a "stack" property in the payload object)

— Edits -

changing function signature to "log", rather than "send"

Debug.log() seems more logical than Debug.send(), so changing function signature.

_log(payload) {
payload = this._addMetadata(payload);
xdmp.log(JSON.stringify(payload)); // logging complete JSON
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we throw an error here if for some reason we can't write to the log?

@aebadirad aebadirad merged commit f3765f1 into Marklogic-retired:develop Feb 11, 2019
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