This article is written by a student studying JS etc. instead of a memo. Don't expect the content.
This time it will be done on Ubuntu, so start the virtual environment with iTerm2.
Where it started
Move to the directory where Ubuntu is installed. vagrant up is a command to start Ubuntu installed on a virtual PC, and vagrant ssh connects to SSH with the Vagrant virtual machine set.
Describe the following contents in the arrow function of http.createServer.
console.info(
'[' + new Date() + '] Requested by ' + reqest.connection.remoteAddress
);
This time, the request to the server is assigned to the variable called reqest. This time, the IP information to which the request was sent is output. I am using console.info, but info is categorized as follows.
Function name | Contents | output |
---|---|---|
info,log | Information to leave from usual | Standard output |
warn,error | warning | Error standard output |
console.error('[' + new Date() + '] Server Error', e);
The above on function is described after the arrow function.
If you actually start the server and a console such as an error is displayed, it is successful.
Recommended Posts