Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: structured logging (JSON) #5179

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

SapphicCode
Copy link
Contributor

Reopening #5118


⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Implements structured logging, as requested by #5107.

This feature can be enabled by using the environment variable UPTIME_KUMA_LOG_FORMAT set to json.

This PR also incorporates the work of #4391 and #4392 (with minor fixes to both as per the linter), for the feature itself I would direct your attention to commit 8a20bee .

Type of change

Please delete any options that are not relevant.

  • User interface (UI)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Before

Code - 2024-09-19 10 24 23

After

Code - 2024-09-19 10 26 47

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 tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

@SapphicCode SapphicCode changed the title Feat/structured logging 2 feat: structured logging (JSON) Oct 9, 2024
@CommanderStorm CommanderStorm added this to the 2.1.0 milestone Oct 9, 2024
@louislam
Copy link
Owner

The problem I saw before:

  • The hide log feature is broken
  • apicache.js don't have to change (That is a 3rd party library, that debug log is too crazy, it keeps printing long long messages to my terminal)

Also I suggest that it should break down into multiple pull requests for easier code review like:

  • feat: structured logging (JSON) (only added the json log part and don't touch existing logic)
  • code refactor: convert and use Settings
  • code refactor: remove deprecated functions and unused functions

Something like that.

…log`

Co-authored-by: Frank Elsinga <frank@elsinga.de>
Closes: louislam#4391

Squashed commit of the following:

commit 828d2a7
Merge: 10f771c dd75890
Author: Frank Elsinga <frank@elsinga.de>
Date:   Fri Sep 13 22:51:25 2024 +0800

    Merge branch 'master' into deprecations

commit 10f771c
Author: Frank Elsinga <frank@elsinga.de>
Date:   Thu Jan 18 22:36:12 2024 +0100

    formatting fixes

commit d737b19
Author: Frank Elsinga <frank@elsinga.de>
Date:   Thu Jan 18 21:27:30 2024 +0100

    migrated all settings to use the `Settings` class

commit c5e26e9
Author: Frank Elsinga <frank@elsinga.de>
Date:   Thu Jan 18 21:04:44 2024 +0100

    removed the deprecated logging functionality

* fix(server/model/monitor): duplicate `Settings.set` for `tlsExpiryNotifyDays`

* fix(eslint): minor linter complaints & a typo
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Closes: louislam#4392

Squashed commit of the following:

commit 75c4c35
Merge: 14e3c3c dd75890
Author: Frank Elsinga <frank@elsinga.de>
Date:   Fri Sep 13 22:46:21 2024 +0800

    Merge branch 'master' into unified-logging-infrastructure

commit 14e3c3c
Merge: d622dfb c919d2c
Author: Frank Elsinga <frank@elsinga.de>
Date:   Mon Jun 3 16:00:56 2024 +0200

    Merge branch 'master' into unified-logging-infrastructure

commit d622dfb
Author: Frank Elsinga <frank@elsinga.de>
Date:   Thu Jan 18 22:31:10 2024 +0100

    unified our logging infrastructure

(and)

build: recompile `utils.js`
Includes a slight refactor in the console logging section, to achieve an unformatted output and reduce complexity.

Resolves: louislam#5107
@SapphicCode
Copy link
Contributor Author

SapphicCode commented Oct 10, 2024

Restructured the commit tree on this branch as requested.

As for the hide log feature, that seems to have been broken since at least 11 months ago, and probably longer than that: Code - 2024-10-10 17 12 21 when the assumption was made that level is uppercase instead of lowercase.

@CommanderStorm
Copy link
Collaborator

when the assumption was made that level is uppercase instead of lowercase

I made that assumption was in #4392 (not in master) regarding that feature that were not accurate. I asumed that if I were to change all usage of log, then making this uppercase would be fine. I forgot to look into this function.

Co-authored-by: Frank Elsinga <frank@elsinga.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants