mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Add log level configuration
This commit is contained in:
parent
bc1ca32991
commit
e11b781fc5
@ -5,6 +5,13 @@ import SubscriptionPlan from 'Common/Types/Billing/SubscriptionPlan';
|
||||
import { JSONObject } from 'Common/Types/JSON';
|
||||
import BillingConfig from './BillingConfig';
|
||||
|
||||
export enum ConfigLogLevel {
|
||||
INFO = 'INFO',
|
||||
WARN = 'WARN',
|
||||
ERROR = 'ERROR',
|
||||
DEBUG = 'DEBUG',
|
||||
}
|
||||
|
||||
export const getAllEnvVars: () => JSONObject = (): JSONObject => {
|
||||
return process.env;
|
||||
};
|
||||
@ -139,3 +146,6 @@ export const ClickhouseDatabase: string =
|
||||
export const GitSha: string = process.env['GIT_SHA'] || 'unknown';
|
||||
|
||||
export const AppVersion: string = process.env['APP_VERSION'] || 'unknown';
|
||||
|
||||
export const LogLevel: ConfigLogLevel =
|
||||
(process.env['LOG_LEVEL'] as ConfigLogLevel) || ConfigLogLevel.ERROR;
|
||||
|
@ -2,6 +2,7 @@ import { SeverityNumber } from '@opentelemetry/api-logs';
|
||||
import OneUptimeTelemetry from './Telemetry';
|
||||
import Exception from 'Common/Types/Exception/Exception';
|
||||
import { JSONObject } from 'Common/Types/JSON';
|
||||
import { ConfigLogLevel, LogLevel } from '../EnvironmentConfig';
|
||||
|
||||
export type LogBody = string | JSONObject | Exception | Error | unknown;
|
||||
|
||||
@ -16,31 +17,51 @@ export default class logger {
|
||||
}
|
||||
|
||||
public static info(message: LogBody): void {
|
||||
this.emit({
|
||||
body: message,
|
||||
severityNumber: SeverityNumber.INFO,
|
||||
});
|
||||
if (
|
||||
LogLevel === ConfigLogLevel.DEBUG ||
|
||||
LogLevel === ConfigLogLevel.INFO
|
||||
) {
|
||||
this.emit({
|
||||
body: message,
|
||||
severityNumber: SeverityNumber.INFO,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static error(message: LogBody): void {
|
||||
this.emit({
|
||||
body: message,
|
||||
severityNumber: SeverityNumber.ERROR,
|
||||
});
|
||||
if (
|
||||
LogLevel === ConfigLogLevel.DEBUG ||
|
||||
LogLevel === ConfigLogLevel.INFO ||
|
||||
LogLevel === ConfigLogLevel.WARN ||
|
||||
LogLevel === ConfigLogLevel.ERROR
|
||||
) {
|
||||
this.emit({
|
||||
body: message,
|
||||
severityNumber: SeverityNumber.ERROR,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static warn(message: LogBody): void {
|
||||
this.emit({
|
||||
body: message,
|
||||
severityNumber: SeverityNumber.WARN,
|
||||
});
|
||||
if (
|
||||
LogLevel === ConfigLogLevel.DEBUG ||
|
||||
LogLevel === ConfigLogLevel.INFO ||
|
||||
LogLevel === ConfigLogLevel.WARN
|
||||
) {
|
||||
this.emit({
|
||||
body: message,
|
||||
severityNumber: SeverityNumber.WARN,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static debug(message: LogBody): void {
|
||||
this.emit({
|
||||
body: message,
|
||||
severityNumber: SeverityNumber.DEBUG,
|
||||
});
|
||||
if (LogLevel === ConfigLogLevel.DEBUG) {
|
||||
this.emit({
|
||||
body: message,
|
||||
severityNumber: SeverityNumber.DEBUG,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static emit(data: {
|
||||
|
@ -85,6 +85,7 @@ The following table lists the configurable parameters of the OneUptime chart and
|
||||
| `internalSmtp.dkimPublicKey` | DKIM Public Key that is set for sending domain | `nil` | |
|
||||
| `internalSmtp.email` | Email address to send emails from | `nil` | |
|
||||
| `internalSmtp.name` | Name to send emails from | `nil` | |
|
||||
| `logLevel` | Can be one of the following - INFO, WARN, ERROR, DEBUG | `ERROR` | |
|
||||
| `incidents.disableAutomaticCreation` | Disable incident creation (use this when your team is overloaded with incidents or in emergencies) | `false` | |
|
||||
| `podSecurityContext` | Pod Security Context. Please refer to Kubernetes docuemntation to set these. This chart depends on other bitnami charts. You will have to set security context for those as well | `{}` | |
|
||||
| `conatinerSecurityContext` | Container Security Context. Please refer to kubernetes documentation to set these. This chart depends on other bitnami charts. You will have to set security context for those as well | `{}` | |
|
||||
|
@ -3,6 +3,8 @@
|
||||
value: {{ $.Values.host }}
|
||||
- name: OTEL_COLLECTOR_HOST
|
||||
value: {{ $.Values.openTelemetryCollectorHost }}
|
||||
- name: LOG_LEVEL
|
||||
value: {{ $.Values.logLevel }}
|
||||
- name: FLUENTD_HOST
|
||||
value: {{ $.Values.fluentdHost }}
|
||||
- name: HTTP_PROTOCOL
|
||||
|
@ -30,6 +30,8 @@ spec:
|
||||
{{- end }}
|
||||
imagePullPolicy: {{ $.Values.image.pullPolicy }}
|
||||
env:
|
||||
- name: LOG_LEVEL
|
||||
value: {{ $.Values.logLevel }}
|
||||
- name: PORT
|
||||
value: {{ $.Values.port.probe | squote }}
|
||||
- name: OPENTELEMETRY_EXPORTER_OTLP_HEADERS
|
||||
|
@ -179,4 +179,6 @@ containerSecurityContext:
|
||||
podSecurityContext:
|
||||
|
||||
|
||||
# This can be one of the following: DEBUG, INFO, WARN, ERROR
|
||||
logLevel: ERROR
|
||||
|
@ -188,5 +188,9 @@ ACCOUNTS_OPENTELEMETRY_EXPORTER_OTLP_HEADERS=
|
||||
ADMIN_DASHBOARD_OPENTELEMETRY_EXPORTER_OTLP_HEADERS=
|
||||
|
||||
|
||||
# This can be one of ERROR, WARN, INFO, DEBUG
|
||||
LOG_LEVEL=ERROR
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -9,6 +9,8 @@ x-common-variables: &common-variables
|
||||
|
||||
FLUENTD_HOST: ${FLUENTD_HOST}
|
||||
|
||||
LOG_LEVEL: ${LOG_LEVEL}
|
||||
|
||||
NODE_ENV: ${ENVIRONMENT}
|
||||
BILLING_ENABLED: ${BILLING_ENABLED}
|
||||
BILLING_PUBLIC_KEY: ${BILLING_PUBLIC_KEY}
|
||||
|
Loading…
Reference in New Issue
Block a user