Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated util.puts by console in server.js script. #375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function HttpServer(handlers) {
HttpServer.prototype.start = function(port) {
this.port = port;
this.server.listen(port);
util.puts("Http Server running at http://localhost:" + port + "/");
console.log("Http Server running at http://localhost:" + port + "/");
};

HttpServer.prototype.parseUrl_ = function(urlString) {
Expand All @@ -56,7 +56,7 @@ HttpServer.prototype.handleRequest_ = function(req, res) {
if (req.headers["user-agent"]) {
logEntry += " " + req.headers["user-agent"];
}
util.puts(logEntry);
console.log(logEntry);
req.url = this.parseUrl_(req.url);
var handler = this.handlers[req.method];
if (!handler) {
Expand Down Expand Up @@ -111,8 +111,8 @@ StaticServlet.prototype.sendError_ = function(req, res, error) {
res.write("<title>Internal Server Error</title>\n");
res.write("<h1>Internal Server Error</h1>");
res.write("<pre>" + escapeHtml(util.inspect(error)) + "</pre>");
util.puts("500 Internal Server Error");
util.puts(util.inspect(error));
console.error("500 Internal Server Error");
console.error(util.inspect(error));
};

StaticServlet.prototype.sendMissing_ = function(req, res, path) {
Expand All @@ -129,7 +129,7 @@ StaticServlet.prototype.sendMissing_ = function(req, res, path) {
" was not found on this server.</p>"
);
res.end();
util.puts("404 Not Found: " + path);
console.error("404 Not Found: " + path);
};

StaticServlet.prototype.sendForbidden_ = function(req, res, path) {
Expand All @@ -146,7 +146,7 @@ StaticServlet.prototype.sendForbidden_ = function(req, res, path) {
" on this server.</p>"
);
res.end();
util.puts("403 Forbidden: " + path);
console.error("403 Forbidden: " + path);
};

StaticServlet.prototype.sendRedirect_ = function(req, res, redirectUrl) {
Expand All @@ -161,7 +161,7 @@ StaticServlet.prototype.sendRedirect_ = function(req, res, redirectUrl) {
'<p>The document has moved <a href="' + redirectUrl + '">here</a>.</p>'
);
res.end();
util.puts("301 Moved Permanently: " + redirectUrl);
console.debug("301 Moved Permanently: " + redirectUrl);
};

StaticServlet.prototype.sendFile_ = function(req, res, path) {
Expand Down