Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 87e8505

Browse files
Implement tty color reset
1 parent b5b4b35 commit 87e8505

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎JavaScript/1-functional/logger.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ const logger = file => {
99
const stream = isTTY ? file : fs.createWriteStream(file);
1010
return (serializer = logger.defaultSerializer) => app => module => kind => {
1111
const color = isTTY ? (logger.colors[kind] || logger.colors.info) : '';
12+
const normal = isTTY ? logger.colors.normal : '';
1213
return msg => {
1314
const date = new Date().toISOString();
1415
const record = { date, kind, app, module, msg };
1516
const line = serializer(record);
16-
stream.write(color + line + '\n');
17+
stream.write(color + line + normal+'\n');
1718
};
1819
};
1920
};
@@ -24,6 +25,7 @@ logger.colors = {
2425
warning: '\x1b[1;33m',
2526
error: '\x1b[0;31m',
2627
info: '\x1b[1;37m',
28+
normal: '\x1b[0m',
2729
};
2830

2931
module.exports = logger;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /