0

I cannot seem to get debug messages to show up in vega in kibana. The docs say I can use the functions warn(), info(), and debug() in expressions and they will print to the console which I assumed is the browser developer console. I cannot get these to work in the vega spec but have only been able to get warn to work somewhat in the developer console.

I understand what I have now doesn't work. I have tried many different combinations in the spec of setting logLevel and calling warn and none work.

My spec so far has:

{
"$schema": "https://vega.github.io/schema/vega/v5.json",
...
"marks":[
    {
    "on":[
        {
          "trigger":"vega.logLevel(vega.Warn);vega.warn('trigger run');",
          "modify":"warn('modify1, run');",
          "values":"warn('values1, run');"
        },
        {
          "trigger":"vega.logger.level('info');warn('trigger run');",
          "modify":"warn('modify1, run');",
          "values":"warn('values1, run');"
        }
    }
],
...
}

The only thing I have gotten to work is going into the developer console. I have not been able to get info() or debug() to work likely because I don't know how to set the logLevel correctly:

VEGA_DEBUG.view.warn("This is a warning");

What does a user need to do to output messages using these debug functions? How does one set the logLevel correctly?

Currn Hyde
  • 57
  • 5

2 Answers2

1

I am not sure Vega expressions have access to the browser's console logging functions like console.warn, console.info, and console.debug directly.

Instead, you could use the datum object to pass the message data and handle the logging in your JavaScript code that interacts with the Vega view. Not sure if this is possible with Kibana though. Have a go..

"signals": [
    {
      "name": "warnMessage",
      "value": "Warning: This is a sample warning message."
    },
    {
      "name": "infoMessage",
      "value": "Info: This is a sample info message."
    },
    {
      "name": "debugMessage",
      "value": "Debug: This is a sample debug message."
    }
  ],
// Load the Vega specification
const spec = { /* your Vega specification JSON object */ };

// Initialize the Vega view
const view = new vega.View(vega.parse(spec))
  .renderer('canvas')
  .initialize(document.querySelector('#view'));

// Add an event listener for mousemove events
view.addEventListener('mousemove', () => {
  // Access signal values
  const warnMessage = view.signal('warnMessage');
  const infoMessage = view.signal('infoMessage');
  const debugMessage = view.signal('debugMessage');

  // Log messages to the console
  console.warn(warnMessage);
  console.info(infoMessage);
  console.debug(debugMessage);
});

// Render the Vega view
view.runAsync();

Happy charting!

Adam

APB Reports
  • 985
  • 10
1

According to Kibana's documentation:

Logging settings in Kibana

You do not need to configure any additional settings to use the logging features in Kibana. Logging is enabled by default and will log at info level using the pattern layout, which outputs logs to stdout.

Configure logging

Log level

Currently we support the following log levels: all, fatal, error, warn, info, debug, trace, off.

Levels are ordered, so all > fatal > error > warn > info > debug > trace > off.

A log record will be logged by the logger if its level is higher than or equal to the level of its logger. Otherwise, the log record is ignored.

The all and off levels can only be used in configuration and are handy shortcuts that allow you to log every log record or disable logging entirely for a specific logger.

Pattern layout

With pattern layout it’s possible to define a string pattern with special placeholders %conversion_pattern that will be replaced with data from the actual log message. By default the following pattern is used: [%date][%level][%logger] %message.

Examples

Hope this helps.

Roy Ing
  • 724
  • 1
  • 2
  • 2