diff --git a/packages/core/src/handlers/base-handler.ts b/packages/core/src/handlers/base-handler.ts index 28cd449b..b3ace37f 100644 --- a/packages/core/src/handlers/base-handler.ts +++ b/packages/core/src/handlers/base-handler.ts @@ -129,7 +129,7 @@ export abstract class BaseHandler handle = (req: http.IncomingMessage, res: http.ServerResponse): void => this.upload(req, res); upload = (req: http.IncomingMessage, res: http.ServerResponse, next?: () => void): void => { - req.on('error', err => this.logger.error(`[request error]: %o`, err)); + req.on('error', err => this.logger.error(`[request error]: %O`, err)); this.cors.preflight(req, res); this.logger.debug(`[request]: %s %s`, req.method, req.url); const handler = this.registeredHandlers.get(req.method as string); @@ -178,7 +178,7 @@ export abstract class BaseHandler ]) as UploadxError; const errorEvent = { ...err, request: pick(req, ['headers', 'method', 'url']) }; this.listenerCount('error') && this.emit('error', errorEvent); - this.logger.error('[error]: %o', errorEvent); + this.logger.error('[error]: %O', errorEvent); if ('aborted' in req && req['aborted']) return; return this.sendError(res, error); }); @@ -226,9 +226,9 @@ export abstract class BaseHandler sendError(res: http.ServerResponse, error: Error): void { const httpError = isUploadxError(error) ? this._errorResponses[error.uploadxErrorCode] - : !isValidationError(error) - ? this.storage.normalizeError(error) - : error; + : isValidationError(error) + ? error + : this.storage.normalizeError(error); const response = this.storage.onError(httpError); this.send(res, response); } diff --git a/packages/core/src/storages/disk-storage.ts b/packages/core/src/storages/disk-storage.ts index 527358a4..59c358e9 100644 --- a/packages/core/src/storages/disk-storage.ts +++ b/packages/core/src/storages/disk-storage.ts @@ -66,7 +66,7 @@ export class DiskStorage extends BaseStorage { } this.accessCheck().catch(err => { this.isReady = false; - this.logger.error('[error]: Could not write to directory: %o', err); + this.logger.error('[error]: Could not write to directory: %O', err); }); } diff --git a/packages/core/src/storages/local-meta-storage.ts b/packages/core/src/storages/local-meta-storage.ts index 9961f011..90236602 100644 --- a/packages/core/src/storages/local-meta-storage.ts +++ b/packages/core/src/storages/local-meta-storage.ts @@ -21,7 +21,7 @@ export class LocalMetaStorage extends MetaStorage { super(config); this.directory = (config?.directory || join(tmpdir(), 'uploadx_meta')).replace(/\\/g, '/'); this.accessCheck().catch(err => { - this.logger.error('[error]: Could not write to directory: %o', err); + this.logger.error('[error]: Could not write to directory: %O', err); }); } diff --git a/packages/core/src/utils/logger.ts b/packages/core/src/utils/logger.ts index 78d7401d..a87d2658 100644 --- a/packages/core/src/utils/logger.ts +++ b/packages/core/src/utils/logger.ts @@ -54,7 +54,7 @@ export class BasicLogger implements Logger { write = (data: unknown[], level: Exclude): void => { if (PriorityOf[level] >= PriorityOf[this._logLevel]) { - const message = formatWithOptions({ colors: true, depth: 1, maxStringLength: 80 }, ...data); + const message = formatWithOptions({ depth: 1, maxStringLength: 80 }, ...data); const timestamp = new Date().toISOString(); this.logger[level](`${timestamp} ${level.toUpperCase()} ${this.label} ${message}`); } @@ -77,4 +77,4 @@ export class BasicLogger implements Logger { } } -export const logger = new BasicLogger({}); +export const logger = new BasicLogger(); diff --git a/packages/gcs/src/gcs-storage.ts b/packages/gcs/src/gcs-storage.ts index fc0902bd..6f598f4d 100644 --- a/packages/gcs/src/gcs-storage.ts +++ b/packages/gcs/src/gcs-storage.ts @@ -124,7 +124,7 @@ export class GCStorage extends BaseStorage { this.accessCheck().catch((err: ClientError) => { this.isReady = false; - this.logger.error('Unable to open bucket: %o', err); + this.logger.error('Unable to open bucket: %O', err); }); } @@ -230,7 +230,7 @@ export class GCStorage extends BaseStorage { return range ? getRangeEnd(range) : 0; } else if (res.ok) { const data = (await res.json()) as Record; - this.logger.debug('uploaded %o', data); + this.logger.debug('uploaded %O', data); return size; } const message = await res.text(); diff --git a/packages/s3/src/s3-storage.ts b/packages/s3/src/s3-storage.ts index ac00e68a..3fd6de12 100644 --- a/packages/s3/src/s3-storage.ts +++ b/packages/s3/src/s3-storage.ts @@ -140,7 +140,7 @@ export class S3Storage extends BaseStorage { } this.accessCheck().catch((err: AWSError) => { this.isReady = false; - this.logger.error('Unable to open bucket: %o', err); + this.logger.error('Unable to open bucket: %O', err); }); }