Skip to content

Commit

Permalink
fix(core): fix debug caller issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Feb 25, 2022
1 parent 23d1809 commit 02c0ee7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Agent as HttpAgent } from 'http'
import type { Agent as HttpsAgent } from 'https'

import Debug from './debug'
const debug = Debug()
const debug = Debug('client')



Expand Down
4 changes: 2 additions & 2 deletions src/commercelayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import * as api from './api'
import { ApiError } from './error'
import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor, ResponseObj } from './interceptor'
import { CommerceLayerStatic } from './static'
import ResourceAdapter, { ResourcesConfig, ResourcesInitConfig } from './resource'
import ResourceAdapter, { ResourcesInitConfig } from './resource'

import Debug from './debug'
const debug = Debug()
const debug = Debug('commercelayer')


const OPEN_API_SCHEMA_VERSION = '2.8.1'
Expand Down
6 changes: 4 additions & 2 deletions src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const debugPrefix = 'clsdk'


/* Retrieve the name of the caller 'module' */
/*
const caller = (): string => {
const err = new Error()
Expand All @@ -43,11 +44,12 @@ const caller = (): string => {
return fileName.replace(/^.*[\\/]/, '').replace('.ts', '')
}
*/


/* Return a debugger for the defined namespace */
const debug = (namespace?: string): Debugger => {
return debuggerFactory(`${debugPrefix}:${namespace || caller()}`)
const debug = (namespace: string): Debugger => {
return debuggerFactory(`${debugPrefix}:${namespace}`)
}


Expand Down
2 changes: 1 addition & 1 deletion src/jsonapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ResourceCreate, ResourceUpdate, ResourceId, ResourceType, Resource
import { isResourceId, isResourceType } from './common'

import Debug from './debug'
const debug = Debug()
const debug = Debug('jsonapi')



Expand Down
2 changes: 1 addition & 1 deletion src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { InterceptorManager } from './interceptor'

import Debug from './debug'
import { QueryParams } from '.'
const debug = Debug()
const debug = Debug('resource')



Expand Down

0 comments on commit 02c0ee7

Please sign in to comment.