jsish
System
Not logged in

Overview

The System object contains all the builtin toplevel commands in Jsi and are also exported as globals:

puts('hi');
System.puts('hi');

The commands in System include standard javascript commands such as:

and non-standard commands such as:

For a complete list of System commands, see Reference.

log, console.log, puts

The puts() command quotes each of its arguments out to stdout.

puts('caught error'
caught error

The log()/console.log commands quotes each of its arguments out to stdout/stderr, and include the file and line number.

log('caught error'
"caught error" --> assert.js:16

If you are debugging a program and need to find where a puts is coming from, try adding to the top

Interp.conf({logOpts:{puts:true}});

The same can be done from the command-line as in ../tests/assert.js:

JSI_INTERP_OPTS='{logOpts:{puts:true}}'   jsish tests/assert.js
"caught error" --> assert.js:16
"K" --> assert.js:24
"caught error2" --> assert.js:28
"this assert failed" --> assert.js:31
"assert also failed" --> assert.js:34
"done" --> assert.js:36

See Logging for more detail.

There are various other options for controlling the output format for puts/log:

JSI_INTERP_OPTS='{logOpts:{puts:true,file:true,before:true,time:true}}'   jsish tests/assert.js
21:04:44.669 assert.js:16 "caught error"
21:04:44.669 assert.js:24 "K"
21:04:44.669 assert.js:28 "caught error2"
21:04:44.669 assert.js:31 "this assert failed"
21:04:44.669 assert.js:34 "assert also failed"
21:04:44.669 assert.js:36 "done"

Debugging

function foo(db) {
  var debug = (db?log:noOp);
  debug("Here is my debug message");
  //...
}

puts("NODEBUG");
foo(0);
puts("DEBUG");
foo(1);

which outputs:

NODEBUG
DEBUG
"Here is my debug message" --> logtest.jsi:3