Skip to content

Commit

Permalink
Merge pull request #264 from matrix-org/remove-winston-daily-rotate-f…
Browse files Browse the repository at this point in the history
…ile-side-effects

Remove winston-daily-rotate-file side-effects if you're not using logging
  • Loading branch information
Half-Shot authored Oct 30, 2020
2 parents 5574b29 + c60353a commit 518ef75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit 518ef75

Please sign in to comment.