Skip to content

Commit 6c27406

Browse files
committed
fix: Fix colored output being applied to file logging
1 parent 2f51e7a commit 6c27406

File tree

4 files changed

+9
-24
lines changed

4 files changed

+9
-24
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ COPY --from=base /usr/local/lib /usr/local/lib
5959

6060
ENV NODE_ENV=production
6161
ENV IS_DOCKER=true
62-
ENV COLORED_CONSOLE=true
62+
ENV COLORED_STD=true
6363
#
6464
#RUN yarn global add patch-package \
6565
# && yarn install --production=true \

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@fortawesome/free-solid-svg-icons": "^6.4.2",
5252
"@fortawesome/react-fontawesome": "^0.2.0",
5353
"@foxxmd/chromecast-client": "^1.0.4",
54-
"@foxxmd/logging": "^0.1.12",
54+
"@foxxmd/logging": "^0.1.13",
5555
"@foxxmd/string-sameness": "^0.4.0",
5656
"@kenyip/backoff-strategies": "^1.0.4",
5757
"@react-nano/use-event-source": "^0.13.0",

src/backend/common/logging.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,11 @@ if (typeof process.env.CONFIG_DIR === 'string') {
1717
logPath = path.resolve(process.env.CONFIG_DIR, './logs');
1818
}
1919

20-
// docker stdout only colorizes if run with `-it` flag or `tty: true` in docker-compose
21-
// but most common outputs and web log viewers (portainer, dozzle) support colors and using those flags/options is not common for most users
22-
// so
23-
// set COLORED_CONSOLE=true in Dockerfile to coerce colorizing output when running in our docker container.
24-
// and using this instead of FORCE_COLOR (used by colorette) so that we only affect console output instead of all streams
25-
const coloredEnv = process.env.COLORED_CONSOLE;
26-
const coloredConsole = (coloredEnv === undefined || coloredEnv === '') ? undefined : parseBool(process.env.COLORED_CONSOLE);
27-
const prettyDefaults: PrettyOptionsExtra = {};
28-
// colorette only does autodetection if `colorize` prop is not present *at all*, rather than just being undefined
29-
// so need to use default object and only add if we detect there is a non-empty value
30-
if(coloredConsole !== undefined) {
31-
prettyDefaults.colorize = coloredConsole;
32-
}
33-
3420
export const initLogger = (): [FoxLogger, Transform] => {
3521
const opts = parseLogOptions({file: false, console: 'debug'})
3622
const stream = new PassThrough({objectMode: true});
3723
const logger = buildLogger('debug', [
38-
buildDestinationStdout(opts.console, prettyDefaults),
24+
buildDestinationStdout(opts.console),
3925
buildDestinationJsonPrettyStream(opts.console, {destination: stream, object: true, colorize: true})
4026
]);
4127
return [logger, stream];
@@ -54,8 +40,7 @@ export const appLogger = async (config: FoxLogOptions = {}): Promise<[FoxLogger,
5440
logBaseDir: typeof process.env.CONFIG_DIR === 'string' ? process.env.CONFIG_DIR : undefined,
5541
destinations: [
5642
buildDestinationJsonPrettyStream(opts.console, {destination: stream, object: true, colorize: true})
57-
],
58-
pretty: prettyDefaults
43+
]
5944
});
6045
return [logger, stream];
6146
}

0 commit comments

Comments
 (0)