mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
move browser log code out to log listener and remove option I added temporarily that wasn't an opiption
This commit is contained in:
@@ -7,9 +7,6 @@ var less;
|
||||
|
||||
/*
|
||||
TODO - options is now hidden - we should expose it on the less object, but not have it "as" the less object
|
||||
alternately even have it on environment
|
||||
e.g. less.environment.options.fileAsync = true;
|
||||
is it weird you do
|
||||
less = { fileAsync: true }
|
||||
then access as less.environment.options.fileAsync ?
|
||||
*/
|
||||
@@ -22,39 +19,7 @@ var environment = less.environment,
|
||||
browserImport = require("./browser-import")(options, isFileProtocol, less.logger);
|
||||
environment.addFileManager(browserImport);
|
||||
|
||||
var logLevel = {
|
||||
debug: 3,
|
||||
info: 2,
|
||||
errors: 1,
|
||||
none: 0
|
||||
};
|
||||
if (!options.loggers) {
|
||||
options.loggers = [{
|
||||
debug: function(msg) {
|
||||
if (options.logLevel >= logLevel.debug) {
|
||||
console.log(msg);
|
||||
}
|
||||
},
|
||||
info: function(msg) {
|
||||
if (options.logLevel >= logLevel.info) {
|
||||
console.log(msg);
|
||||
}
|
||||
},
|
||||
warn: function(msg) {
|
||||
if (options.logLevel >= logLevel.warn) {
|
||||
console.warn(msg);
|
||||
}
|
||||
},
|
||||
error: function(msg) {
|
||||
if (options.logLevel >= logLevel.error) {
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
for(var i = 0; i < options.loggers.length; i++) {
|
||||
less.logger.addListener(options.loggers[i]);
|
||||
}
|
||||
require("./log-listener")(less, options);
|
||||
|
||||
less.env = options.env || (location.hostname == '127.0.0.1' ||
|
||||
location.hostname == '0.0.0.0' ||
|
||||
@@ -64,18 +29,6 @@ less.env = options.env || (location.hostname == '127.0.0.1' ||
|
||||
isFileProtocol ? 'development'
|
||||
: 'production');
|
||||
|
||||
if (!options.hasOwnProperty('disableDataURIs')) {
|
||||
options.disableDataURIs = true;
|
||||
}
|
||||
|
||||
// The amount of logging in the javascript console.
|
||||
// 3 - Debug, information and errors
|
||||
// 2 - Information and errors
|
||||
// 1 - Errors
|
||||
// 0 - None
|
||||
// Defaults to 2
|
||||
less.logLevel = typeof(options.logLevel) != 'undefined' ? options.logLevel : (less.env === 'development' ? logLevel.debug : logLevel.errors);
|
||||
|
||||
// Load styles asynchronously (default: false)
|
||||
//
|
||||
// This is set to `false` by default, so that the body
|
||||
|
||||
43
lib/less-browser/log-listener.js
Normal file
43
lib/less-browser/log-listener.js
Normal file
@@ -0,0 +1,43 @@
|
||||
module.exports = function(less, options) {
|
||||
|
||||
var logLevel_debug = 3,
|
||||
logLevel_info = 2,
|
||||
logLevel_errors = 1,
|
||||
logLevel_none = 0;
|
||||
|
||||
// The amount of logging in the javascript console.
|
||||
// 3 - Debug, information and errors
|
||||
// 2 - Information and errors
|
||||
// 1 - Errors
|
||||
// 0 - None
|
||||
// Defaults to 2
|
||||
options.logLevel = typeof(options.logLevel) !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_debug : logLevel_errors);
|
||||
|
||||
if (!options.loggers) {
|
||||
options.loggers = [{
|
||||
debug: function(msg) {
|
||||
if (options.logLevel >= logLevel_debug) {
|
||||
console.log(msg);
|
||||
}
|
||||
},
|
||||
info: function(msg) {
|
||||
if (options.logLevel >= logLevel_info) {
|
||||
console.log(msg);
|
||||
}
|
||||
},
|
||||
warn: function(msg) {
|
||||
if (options.logLevel >= logLevel_warn) {
|
||||
console.warn(msg);
|
||||
}
|
||||
},
|
||||
error: function(msg) {
|
||||
if (options.logLevel >= logLevel_error) {
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
for(var i = 0; i < options.loggers.length; i++) {
|
||||
less.logger.addListener(options.loggers[i]);
|
||||
}
|
||||
};
|
||||
@@ -47,8 +47,7 @@ var evalCopyProperties = [
|
||||
'sourceMap', // whether to output a source map
|
||||
'importMultiple', // whether we are currently importing multiple copies
|
||||
'urlArgs', // whether to add args into url tokens
|
||||
'javascriptEnabled',// option - whether JavaScript is enabled. if undefined, defaults to true
|
||||
'disableDataURIs' // option - disable data URIs (they will be converted to URL())
|
||||
'javascriptEnabled'// option - whether JavaScript is enabled. if undefined, defaults to true
|
||||
];
|
||||
|
||||
contexts.Eval = function(options, frames) {
|
||||
|
||||
Reference in New Issue
Block a user