Skip to content

Commit aa9c661

Browse files
committed
feat: improvement on log, debug and trace usage.
* Related to NODE-1814.
1 parent a0f1b55 commit aa9c661

File tree

7 files changed

+57
-351
lines changed

7 files changed

+57
-351
lines changed

OTEL.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ const exporter = new JaegerExporter({
5252

5353
7. Deploy the example to OpenShift local
5454

55-
* Uncomment the `require('./tracing.js');` on `app.js`
56-
5755
```
5856
npm install
59-
npm run openshift
57+
npm run openshift:enable:trace
6058
```
6159

6260
8. When you login on Jaeger UI you can see the result like this:

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ $ npm install
1515
$ npm start
1616
```
1717

18-
If you want debug information, you can set `DEBUG` environment variable and start the application:
18+
This will launch the application on port 8080.
1919

20-
```
21-
$ DEBUG=* npm start
22-
```
20+
Other options:
2321

24-
This will launch the application on port 8080.
22+
* `npm run dev` same as `npm start` but with pretty output log.
23+
* `npm run dev:debug` shows debug information.
2524

2625
### OpenShift Local
2726

@@ -38,5 +37,4 @@ $ npm run openshift # Deploys the example app
3837

3938
### OpenTelemetry with OpenShift Distributed Tracing Platform
4039

41-
This [link](./OTEL.md) contains instructions on how to install the
42-
OpenShift Distributed Tracing Platform and enable tracing.
40+
This [link](./OTEL.md) contains instructions on how to install the OpenShift Distributed Tracing Platform and enable tracing.

app.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*
1919
*/
2020

21-
// require('./tracing.js');
22-
2321
const path = require('path');
2422
const express = require('express');
2523
const bodyParser = require('body-parser');

bin/www

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,7 @@
2424
* Module dependencies.
2525
*/
2626

27-
const pinoDebug = require('pino-debug');
28-
const pino = require('pino');
29-
const logger = pino({
30-
transport: {
31-
target: 'pino-pretty'
32-
}
33-
});
34-
pinoDebug(logger);
35-
27+
const logger = require('../logger.js');
3628
const app = require('../app');
3729
const http = require('http');
3830

@@ -93,10 +85,10 @@ function onError (error) {
9385
// handle specific listen errors with friendly messages
9486
switch (error.code) {
9587
case 'EACCES':
96-
console.error(bind + ' requires elevated privileges');
88+
logger.error(bind + ' requires elevated privileges');
9789
process.exit(1);
9890
case 'EADDRINUSE':
99-
console.error(bind + ' is already in use');
91+
logger.error(bind + ' is already in use');
10092
process.exit(1);
10193
default:
10294
throw error;

logger.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const pino = require('pino');
2+
3+
module.exports = pino({});

0 commit comments

Comments
 (0)