From 354e6851e70d7c19106af0d4f14c2b2751e7167d Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Fri, 24 Jan 2020 06:44:55 +0000 Subject: Changes from ages ago --- src/app.ts | 4 ++-- src/files.ts | 8 ++++---- src/logger.ts | 7 ++++++- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/app.ts b/src/app.ts index 393a89e..bffaffc 100644 --- a/src/app.ts +++ b/src/app.ts @@ -41,8 +41,8 @@ class App { * server. */ public constructor(enableLog: boolean) { + logger.setEnabled(enableLog); logger.debug('Constructing router'); - this.logEnabled = enableLog; this.express = ex(); this.express.use((req, res, next) => { if (req.headers.authorisation) { @@ -153,5 +153,5 @@ export default new App(true).express; */ // tslint:disable-next-line:variable-name export const TestApp: () => ex.Express = (): ex.Express => { - return new App(true).express; + return new App(false).express; }; diff --git a/src/files.ts b/src/files.ts index b2440a5..286e073 100644 --- a/src/files.ts +++ b/src/files.ts @@ -28,10 +28,10 @@ const imgQueueSize = profiler.counter({ agg_type: "sum" }) -const BASE_BASE: string = `/cs/scratch/${require("os").userInfo().username}/` -const CONTENT_BASE_DIRECTORY: string = BASE_BASE + 'files'; -const LOG_BASE_DIRECTORY: string = BASE_BASE + 'logs'; -const TEMP_BASE_DIRECTORY: string = BASE_BASE + 'files-temp'; +const BASE_BASE: string = `${__dirname}/../data` +const CONTENT_BASE_DIRECTORY: string = BASE_BASE + '/files'; +const LOG_BASE_DIRECTORY: string = BASE_BASE + '/logs'; +const TEMP_BASE_DIRECTORY: string = BASE_BASE + '/files-temp'; export interface Metadata { version: number; diff --git a/src/logger.ts b/src/logger.ts index bed8f72..a9fca4d 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -344,7 +344,11 @@ export const setDefaults: (defaults: LoggingMetadata) => Logger = ( emerg: makeLogFunction('emerg', defaults), emergency: makeLogFunction('emergency', defaults), shutdown: makeLogFunction('shutdown', defaults), - isEnabled: (): boolean => !basicFileTransport.silent, + isEnabled: (): boolean => !basicLogger.silent, + setEnabled: (x: boolean): void => { + basicLogger.silent = !x; + return; + }, forward: forwardLog, fetch: fetchLogs2, for: setDefaults @@ -389,6 +393,7 @@ export interface Logger { emergency: LogFunction; shutdown: LogFunction; isEnabled: () => boolean; + setEnabled: (x: boolean) => void; forward: (level: LogLevel, message: string, meta: LoggingMetadata) => void; fetch: (level: LogLevel, params?: FetchParams) => Promise; for: (defaults: LoggingMetadata) => Logger; -- cgit v1.2.1