Skip to content

Commit

Permalink
v1.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin committed Mar 5, 2020
1 parent 44d9c17 commit c271d89
Show file tree
Hide file tree
Showing 6 changed files with 1,128 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"

},
"extends": "eslint:recommended"
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CHANGELOG

## v1.1.0

### Changes

* level parameter is now optional for `logExpression`. If omitted, will always log regardless of level.

### Bugfixes

* Fix month being off by one in timestamp.
* Fix typo in function name in type definition for `setLogLevel`.

## v1.0.0

* Initial Release
4 changes: 2 additions & 2 deletions logger.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare function logLevel(level: number): void;
declare function logExpression(msg: any, level: number): void;
declare function setlogLevel(level: number): void;
declare function logExpression(msg: any, level?: number): void;
6 changes: 3 additions & 3 deletions logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ module.exports.setLogLevel = (level) => {
* Log an expression to console at a specific level.
*
* @param {any} msg
* @param {number} level
* @param {number} [level]
*/
module.exports.logExpression = (msg, level) => {
if (level > logLevel) {
if (level !== undefined && level > logLevel) {
return;
}
const now = new Date();
const date = [now.getFullYear(), now.getMonth(), now.getDate()].map((val) => val.toString().padStart(2, '0')).join('-');
const date = [now.getFullYear(), now.getMonth() + 1, now.getDate()].map((val) => val.toString().padStart(2, '0')).join('-');
const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map((val) => val.toString().padStart(2, '0')).join(':');
const datetime = `[${date} ${time}.${now.getMilliseconds().toString().padStart(3, '0').substr(0, 2)}]`;
if (typeof msg === 'object') {
Expand Down
Loading

0 comments on commit c271d89

Please sign in to comment.