Skip to content

Commit

Permalink
fix: hide debug logs
Browse files Browse the repository at this point in the history
use env variable `DEBUG=moneybird` to show moneybird debug logs
  • Loading branch information
UnderKoen committed Apr 20, 2023
1 parent 09f788e commit 145b766
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 100 deletions.
182 changes: 89 additions & 93 deletions example/package-lock.json

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

7 changes: 4 additions & 3 deletions example/package.json
Expand Up @@ -2,12 +2,13 @@
"name": "example",
"version": "1.0.0",
"dependencies": {
"@print-one/moneybird-js": "file:../print-one-moneybird-js-1.0.0.tgz"
"@print-one/moneybird-js": "file:../"
},
"scripts": {
"start": "cd ../ && npm run build && npm pack && cd example && rimraf node_modules package-lock.json && npm i && node ./example.js"
"start": "cd ../ && npm run build && cd example && cross-env DEBUG=moneybird* node ./example.js"
},
"devDependencies": {
"@types/node": "^18.15.11"
"@types/node": "^18.15.12",
"cross-env": "^7.0.3"
}
}
24 changes: 24 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -23,13 +23,15 @@
},
"types": "lib/index.d.ts",
"dependencies": {
"debug": "^4.3.4",
"gaxios": "^5.1.0"
},
"devDependencies": {
"@markforged/nps": "^5.11.2",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.7",
"@types/debug": "^4.1.7",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"eslint": "^8.37.0",
Expand Down
9 changes: 5 additions & 4 deletions src/moneybird.ts
Expand Up @@ -3,6 +3,7 @@ import { IAdministration, MoneybirdOptions } from "./common";
import { Administration } from "./administration";
import { GaxiosOptions } from "gaxios/build/src/common";
import { HTTP } from "./httpHandler";
import debug from "debug";

export class Moneybird implements HTTP {
private readonly client: Gaxios;
Expand Down Expand Up @@ -61,7 +62,7 @@ export class Moneybird implements HTTP {
* @param options The options for the request
*/
public async GET<T>(url: string, options: GaxiosOptions = {}): Promise<T> {
console.debug(`GET ${url}`);
debug("moneybird")(`GET ${url}`);

const response = await this.client.request<T>({
method: "GET",
Expand All @@ -85,7 +86,7 @@ export class Moneybird implements HTTP {
data: unknown,
options: GaxiosOptions = {}
): Promise<T> {
console.debug(`POST ${url}`);
debug("moneybird").log(`POST ${url}`);

const response = await this.client.request<T>({
method: "POST",
Expand All @@ -110,7 +111,7 @@ export class Moneybird implements HTTP {
data: unknown,
options: GaxiosOptions = {}
): Promise<T> {
console.debug(`PATCH ${url}`);
debug("moneybird").log(`PATCH ${url}`);

const response = await this.client.request<T>({
method: "PATCH",
Expand All @@ -130,7 +131,7 @@ export class Moneybird implements HTTP {
* @param options The options for the request
*/
public async DELETE<T>(url: string, options: GaxiosOptions = {}): Promise<T> {
console.debug(`DELETE ${url}`);
debug("moneybird").log(`DELETE ${url}`);

const response = await this.client.request<T>({
method: "DELETE",
Expand Down

0 comments on commit 145b766

Please sign in to comment.