From 6d34829263b1ee2a86b141016b99df2290c43f62 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sat, 6 Mar 2021 18:17:21 +0100 Subject: [PATCH] Switch to new swaf logger --- .../GiteaRepoLatestReleaseController.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/controllers/GiteaRepoLatestReleaseController.ts b/src/controllers/GiteaRepoLatestReleaseController.ts index 88d08c7..b749860 100644 --- a/src/controllers/GiteaRepoLatestReleaseController.ts +++ b/src/controllers/GiteaRepoLatestReleaseController.ts @@ -2,13 +2,13 @@ import Controller from "swaf/Controller"; import {NextFunction, Request, Response} from "express"; import * as https from "https"; import config from "config"; -import {log} from "swaf/Logger"; import {NotFoundHttpError, ServiceUnavailableHttpError} from "swaf/HttpError"; import * as fs from "fs"; import {promisify} from "util"; import path from "path"; import sendRanges, {SendRangeGetStreamFn} from "send-ranges"; import mime from "mime"; +import {logger} from "swaf/Logger"; export const ASSETS_BASE_DIR = config.get('assets_base_dir'); @@ -18,7 +18,7 @@ export default class GiteaRepoLatestReleaseController extends Controller { } protected async getFile(req: Request, res: Response, next: NextFunction): Promise { - log.info('Serving ' + req.path + ' ...'); + logger.info('Serving ' + req.path + ' ...'); const {owner, name, file} = req.params; if (!owner || !name) return next(); @@ -39,7 +39,7 @@ export default class GiteaRepoLatestReleaseController extends Controller { for (const release of releases) { for (const asset of release.assets) { if (asset.name === file) { - log.debug('Download', asset.browser_download_url); + logger.debug('Download', asset.browser_download_url); return await this.download(req, res, next, { repo: { owner: owner, @@ -57,7 +57,7 @@ export default class GiteaRepoLatestReleaseController extends Controller { } throw new NotFoundHttpError('Asset', req.url); } else { - log.debug('List files'); + logger.debug('List files'); return res.render('list-files', { owner: owner, name: name, @@ -70,7 +70,7 @@ export default class GiteaRepoLatestReleaseController extends Controller { }); }); httpRequest.on('error', err => { - log.error(err); + logger.error(err); }); httpRequest.end(); } @@ -112,7 +112,7 @@ export default class GiteaRepoLatestReleaseController extends Controller { await promisify(fs.rename)(tmpAssetPath, assetPath); } - log.debug('Download', assetPath, downloadProperties.asset.name); + logger.debug('Download', assetPath, downloadProperties.asset.name); sendRanges(async _ => { const filePath = assetPath; @@ -126,7 +126,7 @@ export default class GiteaRepoLatestReleaseController extends Controller { })(req, res, (err: unknown) => { if (err) return next(err); - log.info('Fallback to express download.'); + logger.info('Fallback to express download.'); // Respond return res.download(assetPath, downloadProperties.asset.name);