fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
smartxml: fix
[fnpeditor.git]
/
src
/
fnpjs
/
logging
/
logging.js
diff --git
a/src/fnpjs/logging/logging.js
b/src/fnpjs/logging/logging.js
index
4237f65
..
23dbb24
100644
(file)
--- a/
src/fnpjs/logging/logging.js
+++ b/
src/fnpjs/logging/logging.js
@@
-4,6
+4,7
@@
define(function(require) {
var _ = require('libs/underscore'),
handlers = require('fnpjs/logging/handlers'),
var _ = require('libs/underscore'),
handlers = require('fnpjs/logging/handlers'),
+ formatters = require('fnpjs/logging/formatters'),
config = {},
levels = ['debug', 'info', 'warning', 'error', 'critical'];
config = {},
levels = ['debug', 'info', 'warning', 'error', 'critical'];
@@
-27,22
+28,35
@@
_.extend(Logger.prototype, {
this.config.handlers.forEach(function(handlerName) {
var handlerConfig = config.handlers[handlerName],
handler = handlerConfig.handler,
this.config.handlers.forEach(function(handlerName) {
var handlerConfig = config.handlers[handlerName],
handler = handlerConfig.handler,
- handlerLevel = handlerConfig.level || 'info';
+ formatter = handlerConfig.formatter,
+ handlerLevel = handlerConfig.level || 'info',
+ record = {
+ originalMessage: message,
+ level: level,
+ loggerName: this.name,
+ data: data
+ };
if(typeof handler === 'string') {
handler = handlers[handlerConfig.handler];
}
if(typeof handler === 'string') {
handler = handlers[handlerConfig.handler];
}
+ if(typeof formatter === 'string') {
+ if(formatter.indexOf('%') !== -1) {
+ formatter = formatters.fromFormatString(formatter);
+ } else {
+ formatter = formatters[handlerConfig.formatter];
+ }
+ }
if(!handler) {
throw new Error('Unknown handler: ' + handlerName);
}
if(!handler) {
throw new Error('Unknown handler: ' + handlerName);
}
+ if(!formatter) {
+ formatter = formatters.noop;
+ }
if(levels.indexOf(handlerLevel) !== -1 && levels.indexOf(level) >= levels.indexOf(handlerLevel)) {
if(levels.indexOf(handlerLevel) !== -1 && levels.indexOf(level) >= levels.indexOf(handlerLevel)) {
- handler({
- message: message,
- level: level,
- loggerName: this.name,
- data: data
- });
+ record.message = formatter(record);
+ handler(record);
}
}.bind(this));
}
}
}.bind(this));
}