Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/log-0.0.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,21 @@ LogJS.api.Log = function Log(_opts) {
var name = Utils.getOrElse(opts.name, self.constructor.name);
var enabled = Utils.getOrElse(opts.enabled, true);
var curILevel = Level.strToInt(opts.level);
var timeStampCreator = null;

// Log level can be passed as string or number.
// var levelAny = getOrElse(opts.name, self.constructor.name);

self.getName = function() {
return name;
};

self.setTimeStampCreator = function (fn) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have small documentation or reference about this TimeStampCreator

if (typeof fn !== "function" && fn != null) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& fn != null is redundant. You already test it for a function type

throw new Error("Timestamp creator has to be a function");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use 4-space indentiation

}
timeStampCreator = fn;
};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format this bracet


/** @return {string} Current logging level. */
self.getLevel = function() {
Expand Down Expand Up @@ -235,7 +243,8 @@ LogJS.api.Log = function Log(_opts) {
msg = "" + _msg;
}

var dateTime = moment(new Date()).format('HH:mm:ss.SSS');
var cDate = new Date();
var dateTime = self.timeStampCreator? self.timeStampCreator(cDate) : cDate.toLocaleString();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format this line Creator? self -> Creator ? self

var fixedLevel = Level.intToFixedStr(ilvl);

// TODO: Use patterns from config.
Expand Down Expand Up @@ -324,4 +333,4 @@ LogJS.get = function(opts) {
};

/** Default log */
LogJS.root = LogJS.get({name: "Log.js"});
LogJS.root = LogJS.get({name: "Log.js"});