-
Notifications
You must be signed in to change notification settings - Fork 5
The console Object
The console
object sits directly in the Global object. It partially implements the functionality provided by the console
object found in most popular web browsers. The console
object defines the following methods:
-
log([arg1, ..., argN])
- write one or more objects to the standard error stream. -
info([arg1, ..., argN])
- write one or more objects to the standard error stream as informational message. -
warn([arg1, ..., argN])
- write one or more objects to the standard error stream as warning message. -
error([arg1, ..., argN])
- write one or more objects to the standard error stream as error message.
The standard error stream is typically redirected to the MySQL Error Log.
Each of the console
methods log
, info
, error
, and warn
accept a variable list of arguments. A string representation of the argument values is written one after another, and a new line is written after the last argument. These functions always return null
.
The log
method only writes the arguments to the standard error stream. The info
, warn
and error
methods write a message in the following format:
yyyy-mm-dd hh:mm:ss JS_DAEMON [level]: arg1...argN
Where yyyy-mm-dd hh:mm:ss
is the datetime at the time of calling the method, and level
is one of info
, warn
or error
, depending on which of the methods was used. Examples:
mysql> select js('
'> var what = "Hello", who = "World";
'> console.log(what, " ", who, "!");
'> console.info(what, " ", who, "!");
'> console.warn(what, " ", who, "!");
'> console.error(what, " ", who, "!");
'> ') console;
+---------+
| console |
+---------+
| null |
+---------+
1 row in set (0.01 sec)
Messages appended to the error log:
Hello World!
2013-07-04 14:25:44 JS_DAEMON [info]: Hello World!
2013-07-04 14:25:44 JS_DAEMON [warn]: Hello World!
2013-07-04 14:25:44 JS_DAEMON [error]: Hello World!