Commit 9197b5d5 authored by rockyl's avatar rockyl

增加日志

parent f6341219
......@@ -71,8 +71,6 @@ function applyApi(server){
});
server.post('/tinify', async function (req, res, next) {
logger.info('/tinify');
let file = req.files.file;
if(file){
......@@ -91,7 +89,7 @@ function applyApi(server){
'Content-Type': file.type,
});
}catch (e) {
logger.error('/tinify', 'compress failed');
logger.error('/tinify', 'compress failed', e.message);
res.send({
code: 3,
msg: 'compress failed'
......@@ -128,9 +126,17 @@ const server = restify.createServer({
version: '1.0.0'
});
const ignoreUrlLogger = ['/monitor/check'];
server.use(restify.plugins.acceptParser(server.acceptable));
server.use(restify.plugins.queryParser());
server.use(restify.plugins.bodyParser());
server.use(function (req, res, next) {
if (!ignoreUrlLogger.includes(req.url)) {
logger.info(req.url);
}
return next();
});
applyApi(server);
......
This diff is collapsed.
......@@ -21,8 +21,6 @@ export default function applyApi(server){
});
server.post('/tinify', async function (req, res, next) {
logger.info('/tinify');
let file = req.files.file;
if(file){
......@@ -41,7 +39,7 @@ export default function applyApi(server){
'Content-Type': file.type,
});
}catch (e) {
logger.error('/tinify', 'compress failed');
logger.error('/tinify', 'compress failed', e.message);
res.send({
code: 3,
msg: 'compress failed'
......
......@@ -16,9 +16,17 @@ const server = restify.createServer({
version: '1.0.0'
});
const ignoreUrlLogger = ['/monitor/check'];
server.use(restify.plugins.acceptParser(server.acceptable));
server.use(restify.plugins.queryParser());
server.use(restify.plugins.bodyParser());
server.use(function (req, res, next) {
if (!ignoreUrlLogger.includes(req.url)) {
logger.info(req.url);
}
return next();
});
applyApi(server);
......@@ -42,3 +50,5 @@ server.listen(port, async function () {
}
logger.info('%s listening at %s', server.name, server.url);
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment