Skip to content

Commit ea241a7

Browse files
committed
Standardize console messages in @polar/core
Relates: #41
1 parent de3a1e8 commit ea241a7

File tree

9 files changed

+23
-17
lines changed

9 files changed

+23
-17
lines changed

packages/core/src/components/MapContainer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export default Vue.extend({
198198
}
199199
// always print status code for debugging purposes
200200
console.error(
201-
`Ping to "${service.id}" returned "${statusCode}".`
201+
`@polar/core: Ping to "${service.id}" returned "${statusCode}".`
202202
)
203203
// always add to error log for listener purposes
204204
this.$store.commit('setErrors', [
@@ -211,7 +211,7 @@ export default Vue.extend({
211211
])
212212
}
213213
})
214-
.catch(console.error)
214+
.catch((e) => console.error('@polar/core', e))
215215
)
216216
},
217217
updateHasSmallDisplay() {

packages/core/src/monkeyHeaderLoader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function customLoader(tile, url) {
2828
tile.getImage().src = URL.createObjectURL(blob)
2929
}
3030
})
31-
.catch(console.error)
31+
.catch((e) => console.error('@polar/core', e))
3232
}
3333

3434
// Original addLayer method

packages/core/src/storeModules/capabilities.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const CapabilitiesModule: Module<CoreCapabilitiesState, object> = {
2525
const previous = getters.capabilities[id]
2626
if (typeof previous !== 'undefined' && previous !== null) {
2727
console.warn(
28-
`Re-fired loadCapabilities on id '${id}' albeit the GetCapabilities have already been successfully fetched. No re-fetch will occur.`
28+
`@polar/core: Re-fired loadCapabilities on id '${id}' albeit the GetCapabilities have already been successfully fetched. No re-fetch will occur.`
2929
)
3030
return
3131
}
@@ -35,7 +35,9 @@ export const CapabilitiesModule: Module<CoreCapabilitiesState, object> = {
3535

3636
const service = rawLayerList.getLayerWhere({ id })
3737
if (!service || !service.url || !service.version || !service.typ) {
38-
console.error(`Missing data for service with id '${id}': ${service}`)
38+
console.error(
39+
`@polar/core: Missing data for service '${service}' with id '${id}'.`
40+
)
3941
return
4042
}
4143

@@ -46,8 +48,8 @@ export const CapabilitiesModule: Module<CoreCapabilitiesState, object> = {
4648
.then((string) => commit('addCapabilities', { id, string }))
4749
.catch((e) => {
4850
console.error(
49-
e,
50-
`Capabilities from ${capabilitiesUrl} could not be fetched.`
51+
`@polar/core: Capabilities from ${capabilitiesUrl} could not be fetched.`,
52+
e
5153
)
5254
commit('addCapabilities', { id, string: null })
5355
})
@@ -69,7 +71,10 @@ export const CapabilitiesModule: Module<CoreCapabilitiesState, object> = {
6971
const json = parser.read(xml)
7072
return json
7173
} catch (e) {
72-
console.error(e, `Error reading xml for id '${id}': ${xml}`)
74+
console.error(
75+
`@polar/core: Error reading xml '${xml}' for id '${id}'.`,
76+
e
77+
)
7378
}
7479
}
7580
return null

packages/core/src/utils/addPlugins.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ export default function addPlugins(this, plugins) {
66
plugins.forEach((initializePlugin) => initializePlugin(instance))
77
return instance
88
} catch (error) {
9-
console.error('Map creation failed.')
10-
console.error(error)
9+
console.error('@polar/core: Map creation failed.', error)
1110
}
1211
}
1312
}

packages/core/src/utils/createMap/makeShadowRoot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const makeShadowRoot = (containerId: string): Promise<ShadowRoot> =>
5757
return
5858
}
5959
console.error(
60-
`containerId "${containerId}" not found on website.
60+
`@polar/core: containerId "${containerId}" not found on website.
6161
POLAR map client won't render.
6262
Retrying in ${waitTime}ms ...`
6363
)

packages/core/src/utils/createMap/pullPolarStyleToShadow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const pullPolarStyleToShadow = (
1818

1919
if (!devMode) {
2020
console.warn(
21-
`Stylesheets have been pulled to the ShadowDOM. This mechanism is deprecated and will be removed in the next major version. In the future, POLAR will try to create the relevant style nodes itself, and can be configured as to where the file to be imported is located. This removes the flash of misstyled content POLAR could previously produce on the outlying page, and is an overall more clean solution. See the @polar/core documentation, field 'stylePath'.`
21+
`@polar/core: Stylesheets have been pulled to the ShadowDOM. This mechanism is deprecated and will be removed in the next major version. In the future, POLAR will try to create the relevant style nodes itself, and can be configured as to where the file to be imported is located. This removes the flash of misstyled content POLAR could previously produce on the outlying page, and is an overall more clean solution. See the @polar/core documentation, field 'stylePath'.`
2222
)
2323
}
2424
} else {
@@ -27,7 +27,7 @@ export const pullPolarStyleToShadow = (
2727
link.rel = 'stylesheet'
2828
link.onerror = (e) =>
2929
console.error(
30-
`core.createMap: Couldn't find required stylesheets, map won't render. ${
30+
`@polar/core: Couldn't find required stylesheets, map won't render. ${
3131
stylePath === defaultStylePath
3232
? `The default stylePath ${defaultStylePath} did not work. Please check @polar/core's documentation of 'stylePath' on how this can be configured.`
3333
: `It seems the provided stylePath (${stylePath}) did not work. Please verify its correctness. The value should be given as it would be correct in a link tag's href.`

packages/core/src/utils/createMap/pullVuetifyStyleToShadow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const pullVuetifyStyleToShadow = (shadowRoot: ShadowRoot) => {
66
const vuetifyStyle = document.getElementById('vuetify-theme-stylesheet')
77
if (vuetifyStyle === null) {
88
console.error(
9-
`The POLAR map client did not find the vuetify theme stylesheet. It is supposed to be created programmatically. This is probably a bug in POLAR.`
9+
`@polar/core: The POLAR map client did not find the vuetify theme stylesheet. It is supposed to be created programmatically. This is probably a bug in POLAR.`
1010
)
1111
return
1212
}

packages/core/src/utils/createMap/updateSizeOnReady.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ export const updateSizeOnReady = (instance: Vue) => {
1818
instance.$store.getters.map.updateSize()
1919
} else if (attemptCounter === 100) {
2020
console.error(
21-
`The POLAR map client could not update its size. The map is probably invisible due to having 0 width or 0 height. This might be a CSS issue – please check the wrapper's size.`
21+
`@polar/core: The POLAR map client could not update its size. The map is probably invisible due to having 0 width or 0 height. This might be a CSS issue – please check the wrapper's size.`
2222
)
2323
} else {
2424
// OL prints warnings – add this log to reduce confusion
2525
// eslint-disable-next-line no-console
26-
console.log(`The map now has dimensions and can be rendered.`)
26+
console.log(
27+
`@polar/core: The map now has dimensions and can be rendered.`
28+
)
2729
clearInterval(intervalId)
2830
}
2931
}, 0)

packages/core/src/utils/markers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const memoizeStyle = (getMarker: GetMarkerFunction): GetMarkerFunction => {
7373
cache.set(style, markerStyle)
7474
if (cache.size > 1000) {
7575
console.warn(
76-
`@polar/core/src/utils/markers.ts: 1000+ styles have been created. This is possibly a memory leak. Please mind that the methods exported by this module are memoized. You *may* be calling the methods with constantly newly generated objects, or maybe there's just a lot of styles.`
76+
`@polar/core: 1000+ styles have been created. This is possibly a memory leak. Please mind that the methods exported by this module are memoized. You *may* be calling the methods with constantly newly generated objects, or maybe there's just a lot of styles.`
7777
)
7878
}
7979
return markerStyle

0 commit comments

Comments
 (0)