I have simple hello world nodejs express application and I just added grunt-nodemon that should watch changes on *.js files. Here is the console output I get when I run grunt
and then change some .js file:
Running "nodemon:dev" (nodemon) task
[nodemon] v1.3.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Example app listening at http://:::3000
[nodemon] restarting due to changes...
[nodemon] starting `node server.js`
Example app listening at http://:::3000
Is there a way to see timestamp prepended to each of these lines in console log? Eg.
18:44:21 - Running "nodemon:dev" (nodemon) task
18:44:21 - [nodemon] v1.3.7
18:44:21 - [nodemon] to restart at any time, enter `rs`
...
I'd like to see in console when was the last server restart. Here is my gruntfile.js:
module.exports = function (grunt) {
grunt.initConfig({
nodemon: {
dev: {
script: 'server.js',
options: {
ext: ['js']
}
}
}
});
grunt.loadNpmTasks('grunt-nodemon');
grunt.registerTask('default', ['nodemon'])
};
Rather than try to modify the output of nodemon, a cleaner approach would be for your application to log the timestamp when it starts up.
If you use the util.log
function rather than console.log
, you'll get the timestamp added automatically to your log messages.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.