mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Logging improvements, wont add 404 requests to daily stats
This commit is contained in:
parent
05b034974c
commit
9f8d8329cd
1 changed files with 4 additions and 18 deletions
22
server.js
22
server.js
|
@ -56,22 +56,6 @@ var highlights = ["public", "static", "manual", "isgetting", "postfeedback",
|
|||
"postquestions"
|
||||
];
|
||||
|
||||
try {
|
||||
var stdin = process.openStdin();
|
||||
stdin.addListener("data", function(d) {
|
||||
var input = d.toString().trim();
|
||||
|
||||
if (input == "hello")
|
||||
console.log("hello, messages: \n" + newMessages);
|
||||
if (input == "clear" || input == "c")
|
||||
console.clear();
|
||||
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("Failed to open STDIN");
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
var newMessages = "";
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
|
@ -84,9 +68,11 @@ app.set('view engine', 'ejs');
|
|||
//});
|
||||
app.use(function(req, res, next) {
|
||||
res.on('finish', function() {
|
||||
console.log(res.statusCode);
|
||||
Log(req, true);
|
||||
if (res.statusCode != 404)
|
||||
stat.LogStat(req.url);
|
||||
});
|
||||
stat.LogStat(req.url);
|
||||
next();
|
||||
});
|
||||
app.use(express.static('public'));
|
||||
|
@ -223,7 +209,7 @@ const httpServer = http.createServer(app);
|
|||
const httpsServer = https.createServer(certs, app);
|
||||
httpServer.listen(port);
|
||||
httpsServer.listen(httpsPort);
|
||||
logger.Log("[STRT]: Server listening on port " + port + "...", logger.GetColor("yellow"));
|
||||
logger.Log("[STRT]: Server listening on port " + port + " (http), and " + httpsPort + " (https)...", logger.GetColor("yellow"));
|
||||
|
||||
function Log(req, toFile) {
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue