Skip to content
Open
Show file tree
Hide file tree
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: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
"email": "klauscfhq@protonmail.com",
"url": "https://klauscfhq.github.io"
},
"maintainers": [
{
"name": "Mario Sinani",
"email": "mariosinani@protonmail.ch",
"url": "https://mariocfhq.github.io"
}
],
"maintainers": [{
"name": "Mario Sinani",
"email": "mariosinani@protonmail.ch",
"url": "https://mariocfhq.github.io"
}],
"engines": {
"node": ">=6"
},
Expand Down Expand Up @@ -47,6 +45,7 @@
"displayScope": true,
"displayBadge": true,
"displayDate": false,
"displayISODate": false,
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.

Looks good!

"displayFilename": false,
"displayLabel": true,
"displayTimestamp": false,
Expand Down
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ The following illustrates all the available options with their respective defaul
"displayScope": true,
"displayBadge": true,
"displayDate": false,
"displayISODate": false,
"displayFilename": false,
"displayLabel": true,
"displayTimestamp": false,
Expand Down Expand Up @@ -407,7 +408,14 @@ Display the badge of the logger.
- Type: `Boolean`
- Default: `false`

Display the current local date in `YYYY-MM-DD` format.
Display the current local date in `YYYY-MM-DD` format.

##### `displayISODate`

- Type: `Boolean`
- Default: `false`

Override `displayDate` format and show the current local date in ISO 8601 `YYYY-MM-DDTHH:mm:ss.TDZ` format.
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.

Display the current local date in ISO 8601 `YYYY-MM-DDTHH:mm:ss.TDZ` format.


##### `displayFilename`

Expand Down
52 changes: 42 additions & 10 deletions signale.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ const pkgConf = require('pkg-conf');
const pkg = require('./package.json');
const defaultTypes = require('./types');

const {green, grey, red, underline, yellow} = chalk;
const {
green,
grey,
red,
underline,
yellow
} = chalk;
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.

Unneeded changes, like this one, should also be removed for the PR to be merged


let isPreviousLogInteractive = false;
const defaults = pkg.options.default;
Expand Down Expand Up @@ -50,6 +56,9 @@ class Signale {
}

get date() {
if (this._config.displayISODate) {
return new Date().toISOString();
}
return new Date().toLocaleDateString();
}

Expand All @@ -60,7 +69,9 @@ class Signale {
get filename() {
const _ = Error.prepareStackTrace;
Error.prepareStackTrace = (error, stack) => stack;
const {stack} = new Error();
const {
stack
} = new Error();
Error.prepareStackTrace = _;

const callers = stack.map(x => x.getFileName());
Expand All @@ -73,7 +84,9 @@ class Signale {
}

get packageConfiguration() {
return pkgConf.sync(namespace, {defaults});
return pkgConf.sync(namespace, {
defaults
});
}

set configuration(configObj) {
Expand All @@ -89,7 +102,9 @@ class Signale {
}

_getLongestLabel() {
const {_types} = this;
const {
_types
} = this;
const labels = Object.keys(_types).map(x => _types[x].label);
return Math.max(...labels.filter(x => x).map(x => x.length));
}
Expand Down Expand Up @@ -138,7 +153,9 @@ class Signale {
util.inspect.styles[x] = type.color || _[x];
});

str = util.formatWithOptions({colors: true}, ...str);
str = util.formatWithOptions({
colors: true
}, ...str);
util.inspect.styles = Object.assign({}, _);
return str;
}
Expand Down Expand Up @@ -173,7 +190,10 @@ class Signale {
return meta;
}

_hasAdditional({suffix, prefix}, args, type) {
_hasAdditional({
suffix,
prefix
}, args, type) {
return (suffix || prefix) ? '' : this._formatMessage(args, type);
}

Expand All @@ -184,8 +204,15 @@ class Signale {
if (args[0] instanceof Error) {
[msg] = args;
} else {
const [{prefix, message, suffix}] = args;
additional = Object.assign({}, {suffix, prefix});
const [{
prefix,
message,
suffix
}] = args;
additional = Object.assign({}, {
suffix,
prefix
});
msg = message ? this._formatMessage(message, type) : this._hasAdditional(additional, args, type);
}
} else {
Expand Down Expand Up @@ -301,7 +328,9 @@ class Signale {
if (name.length === 0) {
throw new Error('No scope name was defined.');
}
return new Signale(Object.assign(this.currentOptions, {scope: name}));
return new Signale(Object.assign(this.currentOptions, {
scope: name
}));
}

unscope() {
Expand Down Expand Up @@ -349,7 +378,10 @@ class Signale {
message.push(...report);

this._log(message.join(' '));
return {label, span};
return {
label,
span
};
}
}
}
Expand Down