Skip to content
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

Remove winston-daily-rotate-file side-effects if you're not using logging #264

Merged
merged 1 commit into from
Oct 30, 2020
Merged
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
1 change: 1 addition & 0 deletions changelog.d/264.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove `winston-daily-rotate-file` side-effects which can throw errors with some installed `winston` versions
8 changes: 6 additions & 2 deletions src/components/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ limitations under the License.
*/
import * as util from "util";
import winston, { Logger, format, Logform } from "winston";
import "winston-daily-rotate-file";
import chalk from "chalk";
import * as Transport from 'winston-transport';
import { DailyRotateFile } from "winston/lib/winston/transports";

type LogLevel = "debug"|"info"|"warn"|"error";

Expand Down Expand Up @@ -155,6 +153,12 @@ class Logging {
}

if (config.files !== undefined) {
// `winston-daily-rotate-file` has side-effects so we don't want to mess anyone up
// unless they want to use logging
require("winston-daily-rotate-file");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { DailyRotateFile } = require("winston/lib/winston/transports");

for (const filename of Object.keys(config.files)) {
const level = config.files[filename];
this.transports.push(new DailyRotateFile({
Expand Down