introduce consistent logging #910

Open
andreasbrett wants to merge 2 commits from andreasbrett/logging into master
andreasbrett commented 3 years ago (Migrated from github.com)
Owner

Description

Make console logging more consistent and prepare for potential fail2ban integration. Log output follows a strict scheme:

$TIMESTAMP_UTC_ISO8601 [$MODULE] $LOGLEVEL: $MESSAGE

Before:
console.error("Start Uptime-Kuma failed due to issue patching the database");

After:
console.error("2021-11-10T05:41:33.571Z [DB] ERROR: Start Uptime-Kuma failed due to issue patching the database");

Timestamps are UTC in ISO8601 format (for now, not sure whether this should be a localized timestamp based on the server's TZ). The "module" name is arbitrary but should be chosen to represent the log source (e.g. "db" for the server/database.js). For the authentication parts in server/server.js I chose "auth" to make this more specific. For notification-providers/matrix.js I chose a more general "notification". You get the point.

I also added some new log messages for logins and 2fa authentication. Reason: in the future I want to monitor Uptime Kuma's logs via fail2ban and ban IPs on ISO/OSI layer 3 if someone is penetrating my UK server or trying to login with unknown usernames etc. The current rate limit feature is nice but it's ISO/OSI layer 7 blocking "only". If some IP is attacking UK, might be worth to block all TCP/UDP traffic for that IP - not just rate limit it for UK.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and test it
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

image
image
image

# Description Make console logging more consistent and prepare for potential fail2ban integration. Log output follows a strict scheme: `$TIMESTAMP_UTC_ISO8601 [$MODULE] $LOGLEVEL: $MESSAGE` Before: `console.error("Start Uptime-Kuma failed due to issue patching the database");` After: `console.error("2021-11-10T05:41:33.571Z [DB] ERROR: Start Uptime-Kuma failed due to issue patching the database");` Timestamps are UTC in ISO8601 format (for now, not sure whether this should be a localized timestamp based on the server's TZ). The "module" name is arbitrary but should be chosen to represent the log source (e.g. "db" for the `server/database.js`). For the authentication parts in `server/server.js` I chose "auth" to make this more specific. For `notification-providers/matrix.js` I chose a more general "notification". You get the point. I also added some new log messages for logins and 2fa authentication. Reason: in the future I want to monitor Uptime Kuma's logs via fail2ban and ban IPs on ISO/OSI layer 3 if someone is penetrating my UK server or trying to login with unknown usernames etc. The current rate limit feature is nice but it's ISO/OSI layer 7 blocking "only". If some IP is attacking UK, might be worth to block all TCP/UDP traffic for that IP - not just rate limit it for UK. ## Type of change - New feature (non-breaking change which adds functionality) ## Checklist - [x] My code follows the style guidelines of this project - [x] I ran ESLint and other linters for modified files - [x] I have performed a self-review of my own code and test it - [x] I have commented my code, particularly in hard-to-understand areas - [x] My changes generate no new warnings - [ ] My code needed automated testing. I have added them (this is optional task) ## Screenshots (if any) ![image](https://user-images.githubusercontent.com/6610451/141291381-df4f18a3-7d8c-4c60-aa8d-0dec9b2067ec.png) ![image](https://user-images.githubusercontent.com/6610451/141292407-4dc39e47-3eeb-4554-96fe-e2fa57e678d2.png) ![image](https://user-images.githubusercontent.com/6610451/141292564-a0cd37b3-1e64-4b39-b265-cd12bd3e611f.png)
This pull request can be merged automatically.
You are not authorized to merge this pull request.
Sign in to join this conversation.
Loading…
There is no content yet.