-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:core): add universal logger funcs and deprecation warnings (
#3538) * chore: add universal logger service * chore: rename to NzLoggerService to avoid conflication with users' * chore: use funcs instead of service * fix: fix record not working * chore: show error all the time * fix: unused * fix: simply usage * fix: remove namespace * revert: tslint * revert: lint * fix: tree * fix: self import * fix: tests * fix: jump over bad test * fix: test * fix: test
- Loading branch information
Showing
23 changed files
with
171 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @license | ||
* Copyright Alibaba.com All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
export const environment = { | ||
isTestMode: false | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @license | ||
* Copyright Alibaba.com All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
// tslint:disable:no-any | ||
import { environment } from '../environments/environment'; | ||
|
||
import { isDevMode } from '@angular/core'; | ||
|
||
const record: Record<string, boolean> = {}; | ||
|
||
export const PREFIX = '[NG-ZORRO]:'; | ||
|
||
function notRecorded(...args: any[]): boolean { | ||
const asRecord = args.reduce((acc, c) => acc + c.toString(), ''); | ||
|
||
if (record[asRecord]) { | ||
return false; | ||
} else { | ||
record[asRecord] = true; | ||
return true; | ||
} | ||
} | ||
|
||
function consoleCommonBehavior(consoleFunc: (...args: any) => void, ...args: any[]): void { | ||
if (environment.isTestMode || (isDevMode() && notRecorded(...args))) { | ||
consoleFunc(...args); | ||
} | ||
} | ||
|
||
// Warning should only be printed in dev mode and only once. | ||
export const warn = (...args: any[]) => consoleCommonBehavior((...arg: any[]) => console.warn(PREFIX, ...arg), ...args); | ||
|
||
export const warnDeprecation = (...args: any[]) => | ||
consoleCommonBehavior((...arg: any[]) => console.error(PREFIX, 'deprecated:', ...arg), ...args); | ||
|
||
// Log should only be printed in dev mode. | ||
export const log = (...args: any[]) => { | ||
if (isDevMode()) { | ||
console.log(PREFIX, ...args); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.