mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Logging fixes / imporvements, voteTodo api
This commit is contained in:
@@ -112,7 +112,7 @@ function Log(msg: string | object, color?: string): void {
|
||||
function LogReq(
|
||||
req: any /*express.Request*/,
|
||||
toFile?: boolean,
|
||||
sc?: string
|
||||
statusCode?: string
|
||||
): void {
|
||||
try {
|
||||
const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||
@@ -124,7 +124,7 @@ function LogReq(
|
||||
return
|
||||
}
|
||||
|
||||
let logEntry = GetRandomColor(ip) + ip + C()
|
||||
let logEntry = logHashed(ip)
|
||||
let dl = DELIM
|
||||
if (req.url.includes('lred')) {
|
||||
dl += C('red')
|
||||
@@ -141,7 +141,13 @@ function LogReq(
|
||||
)
|
||||
}
|
||||
logEntry +=
|
||||
dl + hostname + dl + req.headers['user-agent'] + dl + req.method + dl
|
||||
dl +
|
||||
logHashed(hostname) +
|
||||
dl +
|
||||
req.headers['user-agent'] +
|
||||
dl +
|
||||
req.method +
|
||||
dl
|
||||
|
||||
if (req.session && req.session.user) {
|
||||
logEntry += C('cyan') + req.session.user.id + C() + dl
|
||||
@@ -153,8 +159,8 @@ function LogReq(
|
||||
|
||||
logEntry += GetRandomColor(req.url.split('?')[0]) + req.url
|
||||
|
||||
if (sc !== undefined) {
|
||||
logEntry += dl + sc
|
||||
if (statusCode !== undefined) {
|
||||
logEntry += dl + statusCode
|
||||
}
|
||||
|
||||
logEntry += C()
|
||||
@@ -385,7 +391,7 @@ function C(color?: string): string {
|
||||
if (color === 'magenta') {
|
||||
return '\x1b[35m'
|
||||
}
|
||||
if (color === 'coloryan') {
|
||||
if (color === 'cyan') {
|
||||
return '\x1b[36m'
|
||||
}
|
||||
return '\x1b[0m'
|
||||
|
Reference in New Issue
Block a user