Console & log output functions. Puts something to log with log levels depending on method. In case of command line - echo to stdout.

Arguments, passed to console output functions are transformed to string using util.format call.

Do not create this class directly - use global console already created by UB

  
      console.log('%s is a %s usually with weight less then %dgr', 'apple', 'fruit', 100) //Will output "apple is a fruit usually with weight less than 100gr"
console.log('apple', 'fruit', 100) //will output "apple fruit 100"
console.debug('something') // will output to log only if "Debug" level is serverConfig.logging.levels
console.warn('warning message')
console.error('error message')
  

# new Console ()

Methods

# assert (expression) instance

Similar to assert#ok, but the error message is formatted as util.format(message...).

Arguments:
  • expression:

# debug (*) instance

Output to log with log level Debug

Arguments:
  • : *

# dir (objectObject) instance

Uses util.inspect on obj and prints resulting string to stdout.

Arguments:

# error (*) instance

Output to log with log level Error. In case of OS console echo output to stderr

Arguments:
  • : *

# info (*) instance

Output to log with log level Info (alias for console.log)

Arguments:
  • : *

# log (*) instance

Output to log with log level Info. Internally use util.format for create output, so format chars can be used:

  • %s - String.

  • %d - Number (both integer and float).

  • %j - JSON.

  • % - single percent sign ('%'). This does not consume an argument.

    console.log('%s is a %s usually with weight less than %dgr', 'apple', 'fruit', 100); //Will output "apple is a fruit usually with weight less than 100gr"

    console.log('apple', 'fruit', 100); //will output "apple fruit 100"

    console.log('the object JSON is %j', {a: 12, b: {inner: 11}}); // will output a JSON object instead of [object Object]

Arguments:
  • : *

# readLn () → string instance

Read line from stdin. The end of the line is marked by any of the supported line ending styles, independent of the platform on which the code is running (supported line ending styles are CRLF, LF or CR).

The end-of-line marker is not considered part of the line and is ignored.

  
      console.write('Enter your name:')
const name = console.readLn()
console.write('Hello, ', name, '!')
  

# time (labelString) instance

Mark a time.

Arguments:

# timeEnd (labelstring) instance

Finish timer, record output

Arguments:
  
      console.time('100-elements');
       for (var i = 0; i < 100; i++) {
        ;
     }
     console.timeEnd('100-elements');
  

# traceFunc (ffunction, eventNamestring, objNamestring) instance

If Trace log level is enabled for application and !f._skipEmitterTrace - trace to log what function is called

Arguments:

# warn (*) instance

Output to log with log level Warning. In case of OS console echo output to stderr

Arguments:
  • : *

# write (value*) instance

Write to stdout

Arguments:
  • value: *
  
      console.write('Hello! \n Today is', 2023)