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

Option to configure UPTIME_KUMA_LOG_FORMAT: json or text #5107

Open
1 task done
fsteinke opened this issue Sep 13, 2024 · 1 comment Β· May be fixed by #5118
Open
1 task done

Option to configure UPTIME_KUMA_LOG_FORMAT: json or text #5107

fsteinke opened this issue Sep 13, 2024 · 1 comment Β· May be fixed by #5118
Labels
feature-request Request for new features to be added

Comments

@fsteinke
Copy link

πŸ“‘ I have found these related issues/pull requests

  • Checked and didn't find similar issue

🏷️ Feature Request Type

Settings

πŸ”– Feature description

It would be very helpful for us to have an ENV_VAR to configure the logging format directly.
To be clear, a general option to switch between the current "text" logs and logs in "json" would already be a great benefit.

βœ”οΈ Solution

Extend Logger implementation with a e.g. UPTIME_KUMA_LOG_FORMAT variable that can be set to "text" or "json" with "text" being the default, similar to the implementation of UPTIME_KUMA_HIDE_LOG.

Instead of logging to console as

console.error(timePart, modulePart, levelPart, msgPart);

with the value set to "json" the logging could log like this:

console.error(
  JSON.stringify(
    "timestamp": timePart,
    "module": modulePart,
    "level": levelPart,
    "message": msgPart
  )
);

❓ Alternatives

We have considered that this functionality would be possible by a log management solution, but a direct choice and configuration of the logFormat seems to us like a quick and valuable option to avoid further transformations in upstream solutions for the logs produced by kuma.

πŸ“ Additional Context

n/a

@fsteinke fsteinke added the feature-request Request for new features to be added label Sep 13, 2024
@CommanderStorm
Copy link
Collaborator

Shure, reasonable.
Doing this needs the following PRs to work fully:

If you want to provide a PR to have json as an alternative log output, our contribution guide is here: https://github.com/louislam/uptime-kuma/blob/dd75890364fe9cbdfbef6119da6c126234fa6044/CONTRIBUTING.md

@CommanderStorm CommanderStorm changed the title Option to configure loggingFormat: json or text Option to configure UPTIME_KUMA_LOG_FORMAT: json or text Sep 14, 2024
SapphicCode added a commit to SapphicCode/fork-uptime-kuma that referenced this issue Sep 19, 2024
Includes a slight refactor in the console logging section, to achieve an unformatted output and reduce complexity.

Resolves: louislam#5107
SapphicCode added a commit to SapphicCode/fork-uptime-kuma that referenced this issue Sep 19, 2024
Includes a slight refactor in the console logging section, to achieve an unformatted output and reduce complexity.

Resolves: louislam#5107
SapphicCode added a commit to SapphicCode/fork-uptime-kuma that referenced this issue Sep 19, 2024
Includes a slight refactor in the console logging section, to achieve an unformatted output and reduce complexity.

Resolves: louislam#5107
@SapphicCode SapphicCode linked a pull request Sep 19, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants