Skip to content

Commit bb4a1f1

Browse files
committed
logging: Remove support for Papertrail and LogDNA.
1 parent 7e2de38 commit bb4a1f1

File tree

10 files changed

+17
-189
lines changed

10 files changed

+17
-189
lines changed

.snyk

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ ignore:
5252
- google-auth-library > gcp-metadata > extend:
5353
reason: None given
5454
expires: '2018-09-04T08:34:40.448Z'
55-
- logdna > request > extend:
56-
reason: None given
57-
expires: '2018-09-04T08:34:40.448Z'
5855
- nodegit > node-gyp > request > extend:
5956
reason: None given
6057
expires: '2018-09-04T08:34:40.448Z'
@@ -106,20 +103,12 @@ patch:
106103
'npm:hoek:20180212':
107104
- nodegit > node-pre-gyp > hawk > sntp > hoek:
108105
patched: '2018-07-13T21:22:51.632Z'
109-
logdna > request > hawk > boom > hoek:
110-
patched: '2018-08-05T08:32:40.897Z'
111106
- nodegit > node-gyp > request > hawk > hoek:
112107
patched: '2018-07-13T21:22:51.632Z'
113-
logdna > request > hawk > sntp > hoek:
114-
patched: '2018-08-05T08:32:40.897Z'
115108
- nodegit > node-gyp > request > hawk > sntp > hoek:
116109
patched: '2018-07-13T21:22:51.632Z'
117-
logdna > request > hawk > cryptiles > boom > hoek:
118-
patched: '2018-08-05T08:32:40.897Z'
119110
- nodegit > node-gyp > request > hawk > cryptiles > boom > hoek:
120111
patched: '2018-07-13T21:22:51.632Z'
121-
logdna > request > hawk > hoek:
122-
patched: '2018-08-05T08:32:40.897Z'
123112
- nodegit > node-pre-gyp > hawk > hoek:
124113
patched: '2018-07-13T21:22:51.632Z'
125114
- nodegit > node-pre-gyp > hawk > boom > hoek:

SAAS.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ settings, more precisely at `vpdb.services.raygun`.
1212
[Rollbar](https://rollbar.com) is another crash reporter. Like Raygun, it's configured in the
1313
settings at `vpdb.services.rollbar`.
1414

15-
## LogDNA
16-
17-
[LogDNA](https://logdna.com/) is a log management platform. VPDB sends structured logs,
18-
which makes it possible to filter by request, user, or IP. LogDNA is enabled in the settings
19-
under `vpdb.logging.logdna`.
20-
2115
## Sqreen
2216

2317
[Sqreen](https://www.sqreen.io) provides several security-related features.

config/settings.browserstack.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ module.exports = {
2727
logging: {
2828
level: 'info',
2929
console: { access: true, app: true },
30-
file: { access: null, app: null },
31-
papertrail: { access: false, app: false, options: { } },
32-
logdna: { apiKey: '', env: '', hostname: '' },
30+
file: { access: null, app: null, json: null },
3331
},
3432
skipImageOptimizations: true,
3533
quota: {

config/settings.dist.js

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -203,57 +203,11 @@ module.exports = {
203203
/**
204204
* File location of the application log. Null or empty for no logging.
205205
*/
206-
app: '/var/www/staging/shared/logs/app.log'
207-
},
208-
209-
/**
210-
* Sends logs to Papertrail.
211-
*/
212-
papertrail: {
213-
214-
/**
215-
* Whether to send HTTP access log to Papertrail
216-
*/
217-
access: false,
218-
219-
/**
220-
* Whether to send application log to Papertrail
221-
*/
222-
app: false,
223-
206+
app: '/var/www/staging/shared/logs/app.log',
224207
/**
225-
* Papertrail configuration. Must be set if at least
226-
* one of the two above is set to true.
227-
*
228-
* @see https://github.com/kenperkins/winston-papertrail#usage
229-
*/
230-
options: {
231-
host: '',
232-
port: '',
233-
program: 'vpdb-staging',
234-
colorize: true
235-
}
236-
},
237-
238-
/**
239-
* Sends logs to LogDNA
240-
*/
241-
logdna: {
242-
243-
/**
244-
* The Ingestion Key
245-
*/
246-
apiKey: '',
247-
248-
/**
249-
* The environment passed along for each line
250-
*/
251-
env: '',
252-
253-
/**
254-
* The hostname passed along
208+
* File location of the application log. Null or empty for no logging.
255209
*/
256-
hostname: '',
210+
json: '/var/www/staging/shared/logs/json.log'
257211
},
258212

259213
slack: {

config/settings.protractor.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ module.exports = {
2727
logging: {
2828
level: 'info',
2929
console: { access: true, app: true },
30-
file: { access: null, app: null },
31-
papertrail: { access: false, app: false, options: { } },
32-
logdna: { apiKey: '', env: '', hostname: '' },
30+
file: { access: null, app: null, json: null },
3331
},
3432
skipImageOptimizations: true,
3533
quota: {

config/settings.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ module.exports = {
3838
logging: {
3939
level: process.env.LOGLEVEL || 'info',
4040
console: { access: true, app: true },
41-
file: { access: null, app: null },
42-
papertrail: { access: false, app: false, options: { } },
43-
logdna: { apiKey: '', env: '', hostname: '' },
41+
file: { access: null, app: null, json: null },
4442
},
4543
skipImageOptimizations: true,
4644
quota: {

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"mod-project-name": "vpdb",
4545
"dependencies": {
4646
"@koa/cors": "2.2.2",
47-
"@slack/client": "4.3.1",
47+
"@slack/client": "^4.4.0",
4848
"acl": "0.4.11",
4949
"adm-zip": "0.4.11",
5050
"archiver": "2.1.1",
@@ -71,7 +71,6 @@
7171
"koa-router": "7.4.0",
7272
"koa-send": "5.0.0",
7373
"lodash": "4.17.10",
74-
"logdna": "2.0.4",
7574
"logform": "1.9.1",
7675
"mongoose": "5.2.6",
7776
"mongoose-paginate": "5.0.3",
@@ -176,7 +175,6 @@
176175
"build/app/files/processor/processor.js",
177176
"build/app/common/settings.validator.js",
178177
"build/app/common/middleware/website.middleware.js",
179-
"build/app/common/logger.logdna.transport.js",
180178
"build/app/authentication/strategies/**"
181179
],
182180
"reporter": [

src/app/common/logger.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ import winston from 'winston';
2727
import { config } from './settings';
2828
import { RequestState } from './typings/context';
2929

30-
const LogDna = require('logdna');
31-
3230
class Logger {
3331
private logger: winston.Logger;
34-
private readonly logDnaLogger: any;
3532

3633
constructor(private type: LogType) {
3734
const alignedWithColorsAndTime = logFormat.combine(
@@ -46,16 +43,6 @@ class Logger {
4643
level: config.vpdb.logging.level,
4744
});
4845

49-
/* istanbul ignore next */
50-
if (config.vpdb.logging.logdna.apiKey) {
51-
this.logDnaLogger = LogDna.createLogger(config.vpdb.logging.logdna.apiKey, {
52-
app: 'vpdb',
53-
env: config.vpdb.logging.logdna.env,
54-
hostname: config.vpdb.logging.logdna.hostname,
55-
index_meta: true,
56-
});
57-
}
58-
5946
if (type === 'app') {
6047
this.setupAppLogger();
6148
}
@@ -103,15 +90,6 @@ class Logger {
10390

10491
private log(requestState: RequestState | null, level: string, message: string) {
10592
this.logger.log({ level: this.getWinstonLevel(level), message });
106-
/* istanbul ignore if */
107-
if (this.logDnaLogger) {
108-
const opts = {
109-
timestamp: Date.now(),
110-
level: this.getLogDnaLevel(level),
111-
meta: this.getMeta(requestState),
112-
};
113-
this.logDnaLogger.log(message, opts);
114-
}
11593
}
11694

11795
private setupAppLogger(): void {
@@ -179,18 +157,6 @@ class Logger {
179157
} : { logType: this.type };
180158
}
181159

182-
private getLogDnaLevel(level: string): string {
183-
const map: Map<string, string> = new Map([
184-
['info', 'info'],
185-
['error', 'error'],
186-
['warn', 'warn'],
187-
['verbose', 'debug'],
188-
['debug', 'debug'],
189-
['wtf', 'fatal'],
190-
]);
191-
return map.get(level) || 'info';
192-
}
193-
194160
private getWinstonLevel(level: string): string {
195161
const map: Map<string, string> = new Map([
196162
['info', 'info'],

src/app/common/settings.validator.ts

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,38 +136,16 @@ export const settingValidations = {
136136
return 'App log path is not a folder.';
137137
}
138138
},
139-
},
140-
papertrail: {
141-
access: (bool: any) => {
142-
if (!isBoolean(bool)) {
143-
return 'Papertrail access log must be either true or false';
144-
}
145-
},
146-
app: (bool: any) => {
147-
if (!isBoolean(bool)) {
148-
return 'Papertrail application log must be either true or false';
149-
}
150-
},
151-
options: (bool: any) => {
152-
if (!isObject(bool)) {
153-
return 'Papertrail config must be at least an object, even if it\'s empty.';
154-
}
155-
},
156-
},
157-
logdna: {
158-
apiKey: (str: any) => {
159-
if (!isString(str)) {
160-
return 'API Key must be a string.';
139+
json: (logPath: any) => {
140+
if (!logPath) {
141+
return null;
161142
}
162-
},
163-
env: (str: any) => {
164-
if (!isString(str)) {
165-
return 'Environment must be a string.';
143+
const logDir = dirname(logPath);
144+
if (!existsSync(logDir)) {
145+
return 'Json log path does not exist.';
166146
}
167-
},
168-
hostname: (str: any) => {
169-
if (!isString(str)) {
170-
return 'Hostname must be a string.';
147+
if (!lstatSync(logDir).isDirectory()) {
148+
return 'Json log path is not a folder.';
171149
}
172150
},
173151
},

src/app/common/typings/config.d.ts

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -221,58 +221,13 @@ export interface VpdbConfig {
221221
* File location of the application log. Null or empty for no logging.
222222
*/
223223
app: string,
224-
},
225-
226-
/**
227-
* Sends logs to Papertrail.
228-
*/
229-
papertrail: {
230224

231225
/**
232-
* Whether to send HTTP access log to Papertrail
226+
* File location where both access and app log are written.
233227
*/
234-
access: boolean,
235-
236-
/**
237-
* Whether to send application log to Papertrail
238-
*/
239-
app: boolean,
240-
241-
/**
242-
* Papertrail configuration. Must be set if at least
243-
* one of the two above is set to true.
244-
*
245-
* @see https://github.com/kenperkins/winston-papertrail#usage
246-
*/
247-
options: {
248-
host: string,
249-
port: number,
250-
program: string,
251-
colorize: boolean,
252-
},
228+
json: string,
253229
},
254230

255-
/**
256-
* Sends logs to LogDNA
257-
*/
258-
logdna: {
259-
260-
/**
261-
* The Ingestion Key
262-
*/
263-
apiKey: string,
264-
265-
/**
266-
* The environment passed along for each line
267-
*/
268-
env: string,
269-
270-
/**
271-
* The hostname passed along
272-
*/
273-
hostname: string,
274-
}
275-
276231
slack: {
277232
enabled: boolean,
278233
token: string,

0 commit comments

Comments
 (0)