Skip to content

Improvements to the logging capabilities of DataWeave #47

Open
@GauthierPLM

Description

@GauthierPLM

Current state

Currently, the logging capabilities of DataWeave are pretty limited and do not leverage everything the Java platform has to offer. The log function is pretty simple: it accepts a value, and optionally a message to prepend to the value. There are no way to customise the log level or the category of the log.

In a production context, this limit the use cases of the log function as log acts like a println() more than like a real logging utility.

Having no way to only log some text without printing the value is also an important feature missing from DataWeave log function.

Proposal

To improve DataWeave logging capabilities, I would suggest either extending the log function, or offer a new logging module that would offer the following:

  • Logging helpers to log a message such as Logging::error, Logging::warn, Logging::info, Logging::debug, Logging::trace.
  • A head parameter on every functions to set the log category.
  • An optional head parameter to specify the log level on a generic log function.
  • A set of methods that would return the value parameter but not print it.

This would result in the following new functions:

  • Logging::log(category: String = "", level: String = "INFO", prefix: String = "", value: T): T
  • Logging::error(category: String = "", prefix: String = "", value: T): T
  • Logging::warn(category: String = "", prefix: String = "", value: T): T
  • Logging::info(category: String = "", prefix: String = "", value: T): T
  • Logging::debug(category: String = "", prefix: String = "", value: T): T
  • Logging::trace(category: String = "", prefix: String = "", value: T): T

These methods would be doubled with another set allowing not to print the value passed while still returning it:

  • Logging::log(category: String = "", level: String = "INFO", prefix: String = "", value: T, logValue: Boolean): T
  • Logging::error(category: String = "", prefix: String = "", value: T, logValue: Boolean): T
  • Logging::warn(category: String = "", prefix: String = "", value: T, logValue: Boolean): T
  • Logging::info(category: String = "", prefix: String = "", value: T, logValue: Boolean): T
  • Logging::debug(category: String = "", prefix: String = "", value: T, logValue: Boolean): T
  • Logging::trace(category: String = "", prefix: String = "", value: T, logValue: Boolean): T

These methods signatures would be compatible with the existing log function, offering an easy transition while remaining coherent with the existing core library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions