Skip to content

Commit

Permalink
Extract the magic numbers into the configuration file (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo authored Dec 10, 2018
1 parent df08add commit 1914401
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/constants/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

export const MAX_CLASS_PATH_LENGTH: number = 4096;
export const CHILD_PROCESS_MAX_BUFFER_SIZE: number = 1024 * 1024;
export const LOG_FILE_LEVEL: string = 'info';
export const LOG_FILE_NAME: string = 'java_test_runner.log';
export const LOG_FILE_MAX_SIZE: number = 5 * 1024 * 1024;
export const LOG_FILE_MAX_NUMBER: number = 2;
10 changes: 8 additions & 2 deletions src/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import * as path from 'path';
import { Disposable } from 'vscode';
import * as winston from 'winston';
import { LOG_FILE_NAME } from '../constants/configs';
import { LOG_FILE_LEVEL, LOG_FILE_MAX_NUMBER, LOG_FILE_MAX_SIZE, LOG_FILE_NAME } from '../constants/configs';
import { outputChannelTransport } from './outputChannelTransport';

class Logger implements Disposable {
Expand All @@ -15,7 +15,13 @@ class Logger implements Disposable {
this.storagePath = storagePath;
this.logger = winston.createLogger({
transports: [
new (winston.transports.File)({level: 'info', filename: path.join(this.storagePath, LOG_FILE_NAME), maxsize: 5 * 1024 * 1024, maxFiles: 2, tailable: true}),
new (winston.transports.File)({
level: LOG_FILE_LEVEL,
filename: path.join(this.storagePath, LOG_FILE_NAME),
maxsize: LOG_FILE_MAX_SIZE,
maxFiles: LOG_FILE_MAX_NUMBER,
tailable: true,
}),
outputChannelTransport,
],
});
Expand Down

0 comments on commit 1914401

Please sign in to comment.