-
Notifications
You must be signed in to change notification settings - Fork 2
Update log-0.0.1.js #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
| if (typeof fn !== "function" && fn != null) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| throw new Error("Timestamp creator has to be a function"); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use 4-space indentiation |
||
| } | ||
| timeStampCreator = fn; | ||
| }; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. format this bracet |
||
|
|
||
| /** @return {string} Current logging level. */ | ||
| self.getLevel = function() { | ||
|
|
@@ -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(); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. format this line |
||
| var fixedLevel = Level.intToFixedStr(ilvl); | ||
|
|
||
| // TODO: Use patterns from config. | ||
|
|
@@ -324,4 +333,4 @@ LogJS.get = function(opts) { | |
| }; | ||
|
|
||
| /** Default log */ | ||
| LogJS.root = LogJS.get({name: "Log.js"}); | ||
| LogJS.root = LogJS.get({name: "Log.js"}); | ||
There was a problem hiding this comment.
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