mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-10-23 03:37:39 +00:00
Better logging
This commit is contained in:
43
core/modules/utils/logger.js
Normal file
43
core/modules/utils/logger.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/*\
|
||||
title: $:/core/modules/utils/logger.js
|
||||
type: application/javascript
|
||||
module-type: utils
|
||||
|
||||
A basic logging implementation
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Make a new logger
|
||||
*/
|
||||
function Logger() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Make a log function for a particular component
|
||||
*/
|
||||
Logger.prototype.makeLog = function(componentName) {
|
||||
var self = this;
|
||||
return function(/* args */) {
|
||||
self.log.apply(self.log,[componentName + ":"].concat(Array.prototype.slice.call(arguments,0)));
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
Log a message
|
||||
*/
|
||||
Logger.prototype.log = function(/* args */) {
|
||||
if(console !== undefined && console.log !== undefined) {
|
||||
return Function.apply.call(console.log, console, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
exports.Logger = Logger;
|
||||
|
||||
})();
|
Reference in New Issue
Block a user