问题
Is it possible to turn off sails request logs. Like I'm trying to not see the example pasted below. Because when I run my integration tests, these logs get in the way of the report.
<- PUT /api/v1/entrance/login (361ms 200)
| The requesting user agent has been successfully logged in.
|
| Under the covers, this stores the id of the logged-in user in the session as the `userId` key. The next time this user agent sends a request, assuming it includes a cookie (like a web browser), Sails will automatically make this user id available as req.session.userId in the corresponding action. (Also note that, thanks to the included "custom" hook, when a relevant request is received from a logged-in user, that user's entire record from the database will be fetched and exposed as `req.me`.)
|
°
<- GET /api/v1/user/me/overview/subscribe (26ms 200)
回答1:
It's sails hook. https://www.npmjs.com/package/sails-hook-apianalytics
Read documentation, u can edit logs or disable some of them, or just uninstall hook.
Run npm uninstall sails-hook-apianalytics
on root of project and then lift sails.
回答2:
If you check the sails.js documentation about logs, you can change the level of logs as you want. There are several ways to accomplish that, but i prefer to put the log level in the env file, because some logs are not needed in production but in development make sense and is ease to do this:
// config/env/production.js
module.exports = {
...
log: {
level: 'debug'
}
...
}
回答3:
To disable requests logging only in production, it may be convenient to just add the configuration to config/env/production.js
, leaving the routesToLog
property as an empty array, thereby no logging routine will be bound to any event, so there'll be no overhead whatsoever.
来源:https://stackoverflow.com/questions/55033395/disable-request-logs-in-terminal