Skip to content

Commit f05ecc3

Browse files
committed
fix: adjust implementation
1 parent f8f274b commit f05ecc3

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

core/src/utils/config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,10 @@ export interface IonicConfig {
222222

223223
/**
224224
* Developers may configure the logging level for Ionic Framework.
225-
* This will log all logs at the specified level and above.
226225
*
227-
* - `OFF` will not log any logs.
228-
* - `ERROR` will log all errors.
226+
* - `OFF` will not log any errors or warnings.
229227
* - `WARN` will log all errors and warnings.
228+
* - `ERROR` will log only errors.
230229
*/
231230
logLevel?: 'OFF' | 'ERROR' | 'WARN';
232231

core/src/utils/logging/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { config } from '@global/config';
88
*/
99
export const printIonWarning = (message: string, ...params: any[]) => {
1010
const logLevel = config.get('logLevel', 'WARN');
11-
if (['WARN', 'ERROR'].includes(logLevel)) {
11+
if (['WARN'].includes(logLevel)) {
1212
return console.warn(`[Ionic Warn]: ${message}`, ...params);
1313
}
1414
};
@@ -22,7 +22,7 @@ export const printIonWarning = (message: string, ...params: any[]) => {
2222
*/
2323
export const printIonError = (message: string, ...params: any[]) => {
2424
const logLevel = config.get('logLevel', 'ERROR');
25-
if (['ERROR'].includes(logLevel)) {
25+
if (['ERROR', 'WARN'].includes(logLevel)) {
2626
return console.error(`[Ionic Error]: ${message}`, ...params);
2727
}
2828
};

core/src/utils/logging/test/logging.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ describe('Logging', () => {
2626
});
2727
});
2828

29-
describe("when the logLevel configuration is set to 'ERROR'", () => {
29+
describe("when the logLevel configuration is set to 'WARN'", () => {
3030
it('logs a warning to the console', () => {
31-
config.set('logLevel', 'ERROR');
31+
config.set('logLevel', 'WARN');
3232

3333
printIonWarning('This is a warning message');
3434

3535
expect(consoleWarnSpy).toHaveBeenCalledWith('[Ionic Warn]: This is a warning message');
3636
});
3737
});
3838

39-
describe("when the logLevel configuration is set to 'WARN'", () => {
40-
it('logs a warning to the console', () => {
41-
config.set('logLevel', 'WARN');
39+
describe("when the logLevel configuration is set to 'ERROR'", () => {
40+
it('does not log a warning to the console', () => {
41+
config.set('logLevel', 'ERROR');
4242

4343
printIonWarning('This is a warning message');
4444

45-
expect(consoleWarnSpy).toHaveBeenCalledWith('[Ionic Warn]: This is a warning message');
45+
expect(consoleWarnSpy).not.toHaveBeenCalled();
4646
});
4747
});
4848

@@ -91,12 +91,12 @@ describe('Logging', () => {
9191
});
9292

9393
describe("when the logLevel configuration is set to 'WARN'", () => {
94-
it('does not log an error to the console', () => {
94+
it('logs an error to the console', () => {
9595
config.set('logLevel', 'WARN');
9696

9797
printIonError('This is an error message');
9898

99-
expect(consoleErrorSpy).not.toHaveBeenCalled();
99+
expect(consoleErrorSpy).toHaveBeenCalledWith('[Ionic Error]: This is an error message');
100100
});
101101
});
102102

0 commit comments

Comments
 (0)