Skip to content

Commit

Permalink
Ensure consistent location for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmielnik committed Jan 26, 2021
1 parent 8f563dd commit 7fb0f4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/logger/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os from 'os';
import path from 'path';

export const OUTPUT_DIRECTORY = path.resolve(os.homedir(), '.scrabble-solver', 'logs');
12 changes: 10 additions & 2 deletions packages/logger/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import path from 'path';
import { createLogger, format, transports } from 'winston';

import { OUTPUT_DIRECTORY } from './constants';

const logger = createLogger({
level: 'info',
format: format.combine(
Expand All @@ -12,8 +15,13 @@ const logger = createLogger({
format.prettyPrint(),
),
transports: [
new transports.File({ filename: 'scrabble-solver-error.log', level: 'error' }),
new transports.File({ filename: 'scrabble-solver-all.log' }),
new transports.File({
filename: path.resolve(OUTPUT_DIRECTORY, 'error.log'),
level: 'error',
}),
new transports.File({
filename: path.resolve(OUTPUT_DIRECTORY, 'all.log'),
}),
],
});

Expand Down

0 comments on commit 7fb0f4e

Please sign in to comment.