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: Print logger messages to stdout in production #123

54 changes: 19 additions & 35 deletions apps/user-office-backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/user-office-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@apollo/subgraph": "^0.3.1",
"@user-office-software/duo-localisation": "^1.2.0",
"@user-office-software/duo-logger": "^2.0.2",
"@user-office-software/duo-logger": "^2.1.1",
"@user-office-software/duo-message-broker": "^1.4.0",
"@user-office-software/duo-validation": "^3.4.3",
"@user-office-software/openid": "^1.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ import {
GrayLogLogger,
setLogger,
} from '@user-office-software/duo-logger';

export function configureGraylogLogger() {
const server = process.env.GRAYLOG_SERVER;
const port = process.env.GRAYLOG_PORT;

if (server && port) {
const env = process.env.NODE_ENV || 'unset';
setLogger(
new GrayLogLogger(
setLogger([
new ConsoleLogger(), // Log to console
new GrayLogLogger( // Log to Graylog
server,
parseInt(port),
{ facility: 'DMSC', environment: env, service: 'duo-backend' },
['QueryName', 'UserID']
)
);
),
]);
} else {
setLogger(new ConsoleLogger());
setLogger(new ConsoleLogger()); // Log to console
}
}