Skip to content

Commit 3eeaf58

Browse files
committed
fix(core): replace consoles logs with printIonWarning and printErrorWarning
1 parent ac111ca commit 3eeaf58

File tree

20 files changed

+54
-36
lines changed

20 files changed

+54
-36
lines changed

core/src/components/alert/alert.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Gesture } from '@utils/gesture';
55
import { createButtonActiveGesture } from '@utils/gesture/button-active';
66
import { raf } from '@utils/helpers';
77
import { createLockController } from '@utils/lock-controller';
8+
import { printIonWarning } from '@utils/logging';
89
import {
910
createDelegateController,
1011
createTriggerController,
@@ -318,7 +319,7 @@ export class Alert implements ComponentInterface, OverlayInterface {
318319
// checkboxes and inputs are all accepted, but they cannot be mixed.
319320
const inputTypes = new Set(inputs.map((i) => i.type));
320321
if (inputTypes.has('checkbox') && inputTypes.has('radio')) {
321-
console.warn(
322+
printIonWarning(
322323
`Alert cannot mix input types: ${Array.from(inputTypes.values()).join(
323324
'/'
324325
)}. Please see alert docs for more info.`

core/src/components/item-sliding/item-sliding.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ComponentInterface, EventEmitter } from '@stencil/core';
22
import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core';
33
import { findClosestIonContent, disableContentScrollY, resetContentScrollY } from '@utils/content';
44
import { isEndSide } from '@utils/helpers';
5+
import { printIonWarning } from '@utils/logging';
56
import { watchForOptions } from '@utils/watch-options';
67

78
import { getIonMode } from '../../global/ionic-global';
@@ -343,7 +344,7 @@ export class ItemSliding implements ComponentInterface {
343344
case ItemSide.None:
344345
return;
345346
default:
346-
console.warn('invalid ItemSideFlags value', this.sides);
347+
printIonWarning('invalid ItemSideFlags value', this.sides);
347348
break;
348349
}
349350

core/src/components/menu/menu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { GESTURE_CONTROLLER } from '@utils/gesture';
66
import { shouldUseCloseWatcher } from '@utils/hardware-back-button';
77
import type { Attributes } from '@utils/helpers';
88
import { inheritAriaAttributes, assert, clamp, isEndSide as isEnd } from '@utils/helpers';
9+
import { printIonError } from '@utils/logging';
910
import { menuController } from '@utils/menu-controller';
1011
import { BACKDROP, GESTURE, getPresentedOverlay } from '@utils/overlays';
1112
import { isPlatform } from '@utils/platform';
@@ -215,12 +216,12 @@ export class Menu implements ComponentInterface, MenuI {
215216
const content = this.contentId !== undefined ? document.getElementById(this.contentId) : null;
216217

217218
if (content === null) {
218-
console.error('Menu: must have a "content" element to listen for drag events on.');
219+
printIonError('Menu: must have a "content" element to listen for drag events on.');
219220
return;
220221
}
221222

222223
if (this.el.contains(content)) {
223-
console.error(
224+
printIonError(
224225
`Menu: "contentId" should refer to the main view's ion-content, not the ion-content inside of the ion-menu.`
225226
);
226227
}

core/src/components/nav/nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ export class Nav implements NavOutlet {
820820
const finalNumViews = this.views.length + (insertViews?.length ?? 0) - (removeCount ?? 0);
821821
assert(finalNumViews >= 0, 'final balance can not be negative');
822822
if (finalNumViews === 0) {
823-
console.warn(
823+
printIonWarning(
824824
`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`,
825825
this,
826826
this.el

core/src/components/refresher/refresher.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
printIonContentErrorMsg,
99
} from '@utils/content';
1010
import { clamp, componentOnReady, getElementRoot, raf, transitionEndAsync } from '@utils/helpers';
11+
import { printIonError } from '@utils/logging';
1112
import { ImpactStyle, hapticImpact } from '@utils/native/haptic';
1213

1314
import { getIonMode } from '../../global/ionic-global';
@@ -452,7 +453,7 @@ export class Refresher implements ComponentInterface {
452453

453454
async connectedCallback() {
454455
if (this.el.getAttribute('slot') !== 'fixed') {
455-
console.error('Make sure you use: <ion-refresher slot="fixed">');
456+
printIonError('Make sure you use: <ion-refresher slot="fixed">');
456457
return;
457458
}
458459
const contentEl = this.el.closest(ION_CONTENT_ELEMENT_SELECTOR);

core/src/components/router-outlet/router-outlet.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getTimeGivenProgression } from '@utils/animation/cubic-bezier';
44
import { attachComponent, detachComponent } from '@utils/framework-delegate';
55
import { shallowEqualStringMap, hasLazyBuild } from '@utils/helpers';
66
import { createLockController } from '@utils/lock-controller';
7+
import { printIonError } from '@utils/logging';
78
import { transition } from '@utils/transition';
89

910
import { config } from '../../global/config';
@@ -146,7 +147,7 @@ export class RouterOutlet implements ComponentInterface, NavOutlet {
146147
try {
147148
changed = await this.transition(enteringEl, leavingEl, opts);
148149
} catch (e) {
149-
console.error(e);
150+
printIonError('[ion-router-outlet]', e);
150151
}
151152
unlock();
152153
return changed;

core/src/components/router/router.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ComponentInterface, EventEmitter } from '@stencil/core';
22
import { Component, Element, Event, Listen, Method, Prop } from '@stencil/core';
33
import type { BackButtonEvent } from '@utils/hardware-back-button';
44
import { debounce } from '@utils/helpers';
5+
import { printIonError, printIonWarning } from '@utils/logging';
56

67
import type { AnimationBuilder } from '../../interface';
78
import type { NavigationHookResult } from '../route/route-interface';
@@ -166,14 +167,14 @@ export class Router implements ComponentInterface {
166167
@Method()
167168
async navChanged(direction: RouterDirection): Promise<boolean> {
168169
if (this.busy) {
169-
console.warn('[ion-router] router is busy, navChanged was cancelled');
170+
printIonWarning('[ion-router] router is busy, navChanged was cancelled');
170171
return false;
171172
}
172173
const { ids, outlet } = await readNavState(window.document.body);
173174
const routes = readRoutes(this.el);
174175
const chain = findChainForIDs(ids, routes);
175176
if (!chain) {
176-
console.warn(
177+
printIonWarning(
177178
'[ion-router] no matching URL for ',
178179
ids.map((i) => i.id)
179180
);
@@ -182,7 +183,7 @@ export class Router implements ComponentInterface {
182183

183184
const segments = chainToSegments(chain);
184185
if (!segments) {
185-
console.warn('[ion-router] router could not match path because some required param is missing');
186+
printIonWarning('[ion-router] router could not match path because some required param is missing');
186187
return false;
187188
}
188189

@@ -232,7 +233,7 @@ export class Router implements ComponentInterface {
232233
animation?: AnimationBuilder
233234
): Promise<boolean> {
234235
if (!segments) {
235-
console.error('[ion-router] URL is not part of the routing set');
236+
printIonError('[ion-router] URL is not part of the routing set');
236237
return false;
237238
}
238239

@@ -253,7 +254,7 @@ export class Router implements ComponentInterface {
253254
const routes = readRoutes(this.el);
254255
const chain = findChainForSegments(segments, routes);
255256
if (!chain) {
256-
console.error('[ion-router] the path does not match any route');
257+
printIonError('[ion-router] the path does not match any route');
257258
return false;
258259
}
259260

@@ -275,7 +276,7 @@ export class Router implements ComponentInterface {
275276
try {
276277
changed = await this.writeNavState(node, chain, direction, segments, redirectFrom, index, animation);
277278
} catch (e) {
278-
console.error(e);
279+
printIonError('[ion-router]', e);
279280
}
280281
unlock();
281282
return changed;
@@ -338,7 +339,7 @@ export class Router implements ComponentInterface {
338339
animation?: AnimationBuilder
339340
): Promise<boolean> {
340341
if (this.busy) {
341-
console.warn('[ion-router] router is busy, transition was cancelled');
342+
printIonWarning('[ion-router] router is busy, transition was cancelled');
342343
return false;
343344
}
344345
this.busy = true;

core/src/components/router/utils/dom.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { componentOnReady } from '@utils/helpers';
2+
import { printIonError } from '@utils/logging';
23

34
import type { AnimationBuilder } from '../../../interface';
45

@@ -51,7 +52,7 @@ export const writeNavState = async (
5152
}
5253
return changed;
5354
} catch (e) {
54-
console.error(e);
55+
printIonError('[ion-router]', e);
5556
return false;
5657
}
5758
};

core/src/components/segment-button/segment-button.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Component, Element, Host, Prop, Method, State, Watch, forceUpdate, h }
33
import type { ButtonInterface } from '@utils/element-interface';
44
import type { Attributes } from '@utils/helpers';
55
import { addEventListener, removeEventListener, inheritAttributes } from '@utils/helpers';
6+
import { printIonError, printIonWarning } from '@utils/logging';
67
import { hostContext } from '@utils/theme';
78

89
import { getIonMode } from '../../global/ionic-global';
@@ -75,7 +76,7 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
7576

7677
// Prevent buttons from being disabled when associated with segment content
7778
if (this.contentId && this.disabled) {
78-
console.warn(`Segment Button: Segment buttons cannot be disabled when associated with an <ion-segment-content>.`);
79+
printIonWarning(`Segment Button: Segment buttons cannot be disabled when associated with an <ion-segment-content>.`);
7980
this.disabled = false;
8081
}
8182
}
@@ -102,13 +103,13 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
102103

103104
// If no associated Segment Content exists, log an error and return
104105
if (!segmentContent) {
105-
console.error(`Segment Button: Unable to find Segment Content with id="${this.contentId}".`);
106+
printIonError(`Segment Button: Unable to find Segment Content with id="${this.contentId}".`);
106107
return;
107108
}
108109

109110
// Ensure the found element is a valid ION-SEGMENT-CONTENT
110111
if (segmentContent.tagName !== 'ION-SEGMENT-CONTENT') {
111-
console.error(`Segment Button: Element with id="${this.contentId}" is not an <ion-segment-content> element.`);
112+
printIonError(`Segment Button: Element with id="${this.contentId}" is not an <ion-segment-content> element.`);
112113
return;
113114
}
114115
}

core/src/components/select/select.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { NotchController } from '@utils/forms';
44
import { compareOptions, createNotchController, isOptionSelected } from '@utils/forms';
55
import { focusVisibleElement, renderHiddenInput, inheritAttributes } from '@utils/helpers';
66
import type { Attributes } from '@utils/helpers';
7+
import { printIonWarning } from '@utils/logging';
78
import { actionSheetController, alertController, popoverController, modalController } from '@utils/overlays';
89
import type { OverlaySelect } from '@utils/overlays-interface';
910
import { isRTL } from '@utils/rtl';
@@ -426,14 +427,14 @@ export class Select implements ComponentInterface {
426427
private createOverlay(ev?: UIEvent): Promise<OverlaySelect> {
427428
let selectInterface = this.interface;
428429
if (selectInterface === 'action-sheet' && this.multiple) {
429-
console.warn(
430+
printIonWarning(
430431
`Select interface cannot be "${selectInterface}" with a multi-value select. Using the "alert" interface instead.`
431432
);
432433
selectInterface = 'alert';
433434
}
434435

435436
if (selectInterface === 'popover' && !ev) {
436-
console.warn(
437+
printIonWarning(
437438
`Select interface cannot be a "${selectInterface}" without passing an event. Using the "alert" interface instead.`
438439
);
439440
selectInterface = 'alert';

0 commit comments

Comments
 (0)