Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
feat: add LabShare Logger as a global module - FCS-161
Browse files Browse the repository at this point in the history
  • Loading branch information
dquispe committed May 14, 2020
1 parent a3bed3f commit 72648f6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
7 changes: 7 additions & 0 deletions lib/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const _ = require('lodash'),
status = require('./middleware/status'),
memoryStore = require('memorystore'),
{ LabShareNotifications } = require('@labshare/services-notifications'),
{ LabShareLogger } = require('@labshare/services-logger'),
{ LoopbackProxyApplication } = require('./loopback-proxy-app'),
{ LoopbackLoader } = require('./loopback-loader');

Expand Down Expand Up @@ -207,6 +208,12 @@ class Services {
}
}

const loggerSettings = _.get(this._options, 'log');
if (loggerSettings) {
const logger = new LabShareLogger(loggerSettings);
_.set(global, 'LabShare.Logger', logger);
}

return this.server
}

Expand Down
10 changes: 5 additions & 5 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@labshare/services-auth": "^3.3.0",
"@labshare/services-cache": "^1.19.0",
"@labshare/services-health": "^1.0.5",
"@labshare/services-logger": "^1.1.5",
"@labshare/services-logger": "^1.1.6",
"@labshare/services-notifications": "^1.0.3",
"@loopback/boot": "^1.5.12",
"@loopback/context": "^1.24.0",
Expand Down
16 changes: 14 additions & 2 deletions test/lib/unit/lib/services_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ describe('Services', () => {

port = unusedPort;

options = {services: {
options = {
services: {
logger: loggerMock,
mountPoints: ['/:facilityId'],
main: packagesPath,
Expand All @@ -46,8 +47,17 @@ describe('Services', () => {
authToken: "testAuthToken",
}
}
},
log: {
fluentD: {
tag: 'LabShare Services Test',
},
console: false,
level: 'info',
enableMetadata: true,
}
}} ;
}
};

services = new Services(options);
done();
Expand All @@ -65,6 +75,7 @@ describe('Services', () => {

expect(_.get(global, 'LabShare.IO')).toBeUndefined();
expect(_.get(global, 'LabShare.Notifications')).toBeUndefined();
expect(_.get(global, 'LabShare.Logger')).toBeUndefined();

server = await services.start();

Expand All @@ -80,6 +91,7 @@ describe('Services', () => {
expect(data.headers['access-control-allow-origin']).toBe('*');
expect(data.headers['access-control-allow-credentials']).toBe('true');
expect(_.get(global, 'LabShare.Notifications')).toBeDefined();
expect(_.get(global, 'LabShare.Logger')).toBeDefined();
});

it('provides status endpoint', async () => {
Expand Down

0 comments on commit 72648f6

Please sign in to comment.