mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
More minor logging changes
This commit is contained in:
parent
9f8d8329cd
commit
7cb0a3b378
1 changed files with 6 additions and 6 deletions
12
server.js
12
server.js
|
@ -68,8 +68,7 @@ app.set('view engine', 'ejs');
|
||||||
//});
|
//});
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
res.on('finish', function() {
|
res.on('finish', function() {
|
||||||
console.log(res.statusCode);
|
Log(req, true, res.statusCode);
|
||||||
Log(req, true);
|
|
||||||
if (res.statusCode != 404)
|
if (res.statusCode != 404)
|
||||||
stat.LogStat(req.url);
|
stat.LogStat(req.url);
|
||||||
});
|
});
|
||||||
|
@ -195,13 +194,12 @@ app.get('/servergit', function(req, res) {
|
||||||
app.get('*', function(req, res) {
|
app.get('*', function(req, res) {
|
||||||
res.render('404');
|
res.render('404');
|
||||||
res.status(404);
|
res.status(404);
|
||||||
utils.AppendToFile(logger.GetDateString() + ": " + "404 GET", logFile);
|
// utils.AppendToFile(logger.GetDateString() + ": " + "404 GET", logFile);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('*', function(req, res) {
|
app.post('*', function(req, res) {
|
||||||
res.status(404);
|
res.status(404);
|
||||||
utils.AppendToFile(logger.GetDateString() + ": " + "404 POST", logFile);
|
// utils.AppendToFile(logger.GetDateString() + ": " + "404 POST", logFile);
|
||||||
Log(req, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
stat.Load();
|
stat.Load();
|
||||||
|
@ -211,12 +209,14 @@ httpServer.listen(port);
|
||||||
httpsServer.listen(httpsPort);
|
httpsServer.listen(httpsPort);
|
||||||
logger.Log("[STRT]: Server listening on port " + port + " (http), and " + httpsPort + " (https)...", logger.GetColor("yellow"));
|
logger.Log("[STRT]: Server listening on port " + port + " (http), and " + httpsPort + " (https)...", logger.GetColor("yellow"));
|
||||||
|
|
||||||
function Log(req, toFile) {
|
function Log(req, toFile, sc) {
|
||||||
try {
|
try {
|
||||||
var ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress;
|
var ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress;
|
||||||
var logEntry = "[RSND]: " + ip + ", " + req.headers['user-agent'] +
|
var logEntry = "[RSND]: " + ip + ", " + req.headers['user-agent'] +
|
||||||
" " + req.method + " ";
|
" " + req.method + " ";
|
||||||
logEntry += req.url;
|
logEntry += req.url;
|
||||||
|
if (sc == 404)
|
||||||
|
logEntry += " " + sc;
|
||||||
var color = logger.GetColor("green");
|
var color = logger.GetColor("green");
|
||||||
for (var i = 0; i < highlights.length; i++)
|
for (var i = 0; i < highlights.length; i++)
|
||||||
if (req.url.toLowerCase().includes(highlights[i])) {
|
if (req.url.toLowerCase().includes(highlights[i])) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue