Logging
This document enables us to use the logging facilities that come with Cerny.js. It shows us how to obtain a logger and adjust the log level in the Configuration file cerny.js, so we get to see only those messages that are interesting for us.
Getting a logger
In order to output log statements, we need to obtain a logger object. We can achieve this by including the following line into our code:
OURAPP.doSomething = function() {
var logger = CERNY.Logger("OURAPP.doSomething");
// do something
...
logger.debug("myvar: " + CERNY.dump(myvar"));
...
}
Configuration
CERNY.logger takes one parameter, which is a string
and is called the category of the logger. The category
is a list of names separated by dots, which denote a path in a
hierachy. The closer the name is to the beginning, the higher it
is in the hierachy. In the configuration we can deactivate
loggers on a higher level, but still get the output of more
specific loggers. Here is an example how the Logger configuration
could look like:
CERNY.Configuration = {
Logger: {
"OURAPP": "OFF",
"OURAPP.doSomething": "DEBUG"
},
...
}
Log levels
The log levels are the standard ones that are familiar from Log4j
or deriavtes. They are OFF, FATAL,
ERROR, WARN, INFO,
DEBUG and TRACE. The logger has
corresponding functions in lower case letters for each of these
levels. The meaning of these levels are subject to project
policy. The general distinction between production levels and
development levels is common. The border is usually not strictly
defined. In some teams INFO is the first development
level, in other teams it is DEBUG.

