Skip to content

Commit

Permalink
[server] Set Probot log level according to config
Browse files Browse the repository at this point in the history
  • Loading branch information
geropl committed Sep 15, 2021
1 parent 0d6f3bb commit 7015936
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
8 changes: 7 additions & 1 deletion chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ env:
- name: GITPOD_INSTALLATION_SHORTNAME
value: {{ template "gitpod.installation.shortname" . }}
- name: LOG_LEVEL
value: {{ $gp.log.level | default "debug" | lower | quote }}
value: {{ template "gitpod.loglevel" }}
{{- end -}}

{{- define "gitpod.loglevel" -}}
{{- $ := .root -}}
{{- $gp := .gp -}}
{{ $gp.log.level | default "debug" | lower | quote }}
{{- end -}}

{{- define "gitpod.container.analyticsEnv" -}}
Expand Down
1 change: 1 addition & 0 deletions chart/templates/server-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ data:
{{- if .Values.devBranch }}
"devBranch": "{{ .Values.devBranch }}",
{{- end }}
"logLevel": {{ template "gitpod.loglevel" }},
"license": "{{ .Values.license }}",
"workspaceHeartbeat": {{ $comp.workspaceHeartbeat | toJson }},
"workspaceDefaults": {
Expand Down
1 change: 0 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ components:
githubApp:
enabled: false
authProviderId: "Public-GitHub"
logLevel: "trace"
blockNewUsers:
enabled: false
passlist: []
Expand Down
15 changes: 13 additions & 2 deletions components/server/ee/src/prebuilds/github-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { injectable, inject } from 'inversify';
import { Config } from '../../../src/config';
import { AppInstallationDB, TracedWorkspaceDB, DBWithTracing, UserDB, WorkspaceDB, ProjectDB, TeamDB } from '@gitpod/gitpod-db/lib';
import * as express from 'express';
import { log, LogContext } from '@gitpod/gitpod-protocol/lib/util/logging';
import { log, LogContext, LogrusLogLevel } from '@gitpod/gitpod-protocol/lib/util/logging';
import { WorkspaceConfig, User, Project, StartPrebuildResult } from '@gitpod/gitpod-protocol';
import { MessageBusIntegration } from '../../../src/workspace/messagebus-integration';
import { GithubAppRules } from './github-app-rules';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class GithubApp {
appId: config.githubApp.appId,
privateKey: GithubApp.loadPrivateKey(config.githubApp.certPath),
secret: config.githubApp.webhookSecret,
logLevel: config.githubApp.logLevel as Options["logLevel"],
logLevel: GithubApp.mapToGitHubLogLevel(config.logLevel),
baseUrl: config.githubApp.baseUrl,
})
});
Expand Down Expand Up @@ -393,4 +393,15 @@ export namespace GithubApp {
}
}
}

export function mapToGitHubLogLevel(logLevel: LogrusLogLevel): Options["logLevel"] {
switch (logLevel) {
case "warning":
return "warn";
case "panic":
return "fatal";
default:
return logLevel;
}
}
}
4 changes: 2 additions & 2 deletions components/server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { RateLimiterConfig } from './auth/rate-limiter';
import { CodeSyncConfig } from './code-sync/code-sync-service';
import { ChargebeeProviderOptions, readOptionsFromFile } from "@gitpod/gitpod-payment-endpoint/lib/chargebee";
import * as fs from 'fs';
import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
import { log, LogrusLogLevel } from '@gitpod/gitpod-protocol/lib/util/logging';
import { filePathTelepresenceAware, KubeStage, translateLegacyStagename } from '@gitpod/gitpod-protocol/lib/env';
import { BrandingParser } from './branding-parser';

Expand Down Expand Up @@ -51,6 +51,7 @@ export interface ConfigSerialized {
stage: string;
devBranch?: string;
insecureNoDomain: boolean;
logLevel: LogrusLogLevel;

license?: string;

Expand All @@ -74,7 +75,6 @@ export interface ConfigSerialized {
authProviderId: string;
certPath: string;
marketplaceName: string;
logLevel?: string;
};

definitelyGpDisabled: boolean;
Expand Down

0 comments on commit 7015936

Please sign in to comment.