home scroll deno

Debug Output

Ways to output text for debugging purposes

cncjs has two built-in loggers, one for server-side and one for client-side (in browser)

server side logging (terminal)

The logger from https://github.com/winstonjs/winston
has been integrated into cncjs.
cncjs implements 5 severity levels (./src/server/lib/logger.js):
'error', // 0
'warn', // 1
'info', // 2
'verbose', // 3
'debug', // 4
'silly', // 5

In the source file, add the import

import logger from '../lib/logger';

In a source file, call the log command
Example:
in the file ./src/server/controllers/Grbl/GrblController.js

log.silly(`> ${data}`);

When starting the server, a verbosity option can be selected.(see readme.md)
-v, --verbose Increase the verbosity level (-v, -vv, -vvv)
Start the server with a verbosity option:
bin/cncjs -vv
Everything including and above the severity level will be printed in the terminal.

client side logging (browser)

The logger from https://github.com/cheton/universal-logger
has also been integrated into cncjs.

The file ./src/app/lib/log.js contains the lines

import { TRACE, DEBUG, INFO, WARN, ERROR } from 'universal-logger';
import logger from 'universal-logger';

This file is then used as the import for logging:

import log from './lib/log';
In a source file, call the log command
Example:
in the file ./src/app/index.jsx
log.debug('Create and establish a WebSocket connection');

Follow Me

discord