| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/readjs/node_modules/karma/lib/ |
Upload File : |
// This is the **logger** module for *Karma*. It uses
// [log4js](https://github.com/nomiddlename/log4js-node) to handle and
// configure all logging that happens inside of *Karma*.
// ### Helpers and Setup
var log4js = require('log4js')
var helper = require('./helper')
var constant = require('./constants')
// #### Public Functions
// Setup the logger by passing in the configuration options. It needs
// three arguments:
//
// setup(logLevel, colors, appenders)
//
// * `logLevel`: *String* Defines the global log level.
// * `colors`: *Boolean* Use colors in the stdout or not.
// * `appenders`: *Array* This will be passed as appenders to log4js
// to allow for fine grained configuration of log4js. For more information
// see https://github.com/nomiddlename/log4js-node.
var setup = function (level, colors, appenders) {
// Turn color on/off on the console appenders with pattern layout
var pattern = colors ? constant.COLOR_PATTERN : constant.NO_COLOR_PATTERN
// If there are no appenders use the default one
appenders = helper.isDefined(appenders) ? appenders : [constant.CONSOLE_APPENDER]
appenders = appenders.map(function (appender) {
if (appender.type === 'console') {
if (helper.isDefined(appender.layout) && appender.layout.type === 'pattern') {
appender.layout.pattern = pattern
}
}
return appender
})
// Pass the values to log4js
log4js.setGlobalLogLevel(level)
log4js.configure({
appenders: appenders
})
}
// Setup the logger by passing in the config object. The function sets the
// `colors` and `logLevel` if they are defined. It takes two arguments:
//
// setupFromConfig(config, appenders)
//
// * `config`: *Object* The configuration object.
// * `appenders`: *Array* This will be passed as appenders to log4js
// to allow for fine grained configuration of log4js. For more information
// see https://github.com/nomiddlename/log4js-node.
var setupFromConfig = function (config, appenders) {
var useColors = true
var logLevel = constant.LOG_INFO
if (helper.isDefined(config.colors)) {
useColors = config.colors
}
if (helper.isDefined(config.logLevel)) {
logLevel = config.logLevel
}
setup(logLevel, useColors, appenders)
}
// Create a new logger. There are two optional arguments
// * `name`, which defaults to `karma` and
// If the `name = 'socket.io'` this will create a special wrapper
// to be used as a logger for socket.io.
// * `level`, which defaults to the global level.
var create = function (name, level) {
var logger = log4js.getLogger(name || 'karma')
if (helper.isDefined(level)) {
logger.setLevel(level)
}
return logger
}
// #### Publish
exports.create = create
exports.setup = setup
exports.setupFromConfig = setupFromConfig