Logging fix, ignoring some ips in logging, displaying "DIR" insted of 0MB

This commit is contained in:
MrFry 2019-10-24 19:38:01 +02:00
parent 3c52873422
commit f7b0e727fc
3 changed files with 26 additions and 13 deletions

View file

@ -65,6 +65,19 @@ let modules = {
const app = express()
app.use(function (req, res, next) {
res.on('finish', function () {
logger.LogReq(req, true, res.statusCode)
let toLog = loggableKeywords.some((x) => {
return req.url.includes(x)
})
if (toLog) { logger.LogReq(req) }
if (res.statusCode !== 404) { stat.LogStat(req.url) }
})
next()
})
Object.keys(modules).forEach(function (k, i) {
let x = modules[k]
try {
@ -132,18 +145,6 @@ function setLogTimer () {
setLogTimer()
app.use(function (req, res, next) {
res.on('finish', function () {
logger.LogReq(req, true, res.statusCode)
let toLog = loggableKeywords.some((x) => {
return req.url.includes(x)
})
if (toLog) { logger.LogReq(req) }
if (res.statusCode !== 404) { stat.LogStat(req.url) }
})
next()
})
logger.Log('Node version: ' + process.version)
logger.Log('Listening on port: ' + port)

View file

@ -41,6 +41,11 @@ const colors = [
'cyan'
]
let noLogips = utils.ReadFile('./nolog').split('\n')
setInterval(() => {
noLogips = utils.ReadFile('./nolog').split('\n')
}, 1000 * 60 * 30)
function GetDateString () {
const m = new Date()
const d = m.getFullYear() + '/' +
@ -64,6 +69,13 @@ function LogReq (req, toFile, sc) {
try {
let ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
let nolog = noLogips.some((x) => {
return x.includes(ip)
})
if (nolog) {
return
}
let logEntry = GetRandomColor(ip) + ip + C()
let dl = DELIM
if (req.url.includes('lred')) {

View file

@ -88,7 +88,7 @@
<%=folders[i].mtime %>
</td>
<td style='width:10%;'>
<%=folders[i].size %> MB
<%= folders[i].size === 0 ? "Dir" : folders[i].size + 'MB' %>
</td>
</tr>
</table>