Skip to content

Commit

Permalink
fix fetch error handling in datadog logger
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 2, 2023
1 parent 023e8b8 commit f7c68cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 8 additions & 9 deletions dev/loglevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const broker = new ServiceBroker({
//autoPadding: true
}
},
{
/*{
type: "File",
options: {
folder: "d:/logs",
filename: "moleculer-{date}.log",
formatter: "full"
}
}
}*/
/*{
type: "File",
options: {
Expand Down Expand Up @@ -84,11 +84,10 @@ const broker = new ServiceBroker({
}
}
},*/
/*{
{
type: "Datadog",
options: {
}
}*/
options: {}
}
],
logLevel: {
"MY.**": "trace",
Expand Down Expand Up @@ -120,11 +119,11 @@ const schema = {
}
};

broker.createService({ ...schema, name: 'greeter', version: 2 });
broker.createService({ ...schema, name: "greeter", version: 2 });

broker.createService({ ...schema, name: 'test' });
broker.createService({ ...schema, name: "test" });

broker.createService({ ...schema, name: 'hello' });
broker.createService({ ...schema, name: "hello" });

const myLogger = broker.getLogger("my.custom.module");

Expand Down
5 changes: 3 additions & 2 deletions src/loggers/datadog.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ class DatadogLogger extends BaseLogger {
"Content-Type": "application/json"
}
})
.then((/*res*/) => {
// console.info("Logs are uploaded to DataDog. Status: ", res.statusText);
.then(res => {
if (res.status >= 400) throw new Error(res.statusText);
// console.log("Logs are uploaded to DataDog. Status: ", res.statusText);
})
.catch(err => {
/* istanbul ignore next */
Expand Down

0 comments on commit f7c68cb

Please sign in to comment.