Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
feat(Issue #3): 新增日志类型枚举。
Browse files Browse the repository at this point in the history
  • Loading branch information
netowls-studio committed May 2, 2022
1 parent a03c4bd commit 112c376
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/common/compile/es6/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { sealed } from "./src";
export { sealed, LoggerType } from "./src";
2 changes: 1 addition & 1 deletion packages/common/compile/es6/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// COPYRIGHT © 2006 - 2022 WANG YUCAI. ALL RIGHTS RESERVED.
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION.
// **************************************************************************************************************************
export { sealed } from "./src";
export { sealed, LoggerType } from "./src";
1 change: 1 addition & 0 deletions packages/common/compile/es6/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { sealed } from "./decorators";
export { LoggerType } from "./logging";
1 change: 1 addition & 0 deletions packages/common/compile/es6/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION.
// **************************************************************************************************************************
export { sealed } from "./decorators";
export { LoggerType } from "./logging";
1 change: 1 addition & 0 deletions packages/common/compile/es6/src/logging/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { LoggerType } from "./logger-type";
5 changes: 5 additions & 0 deletions packages/common/compile/es6/src/logging/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// **************************************************************************************************************************
// COPYRIGHT © 2006 - 2022 WANG YUCAI. ALL RIGHTS RESERVED.
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION.
// **************************************************************************************************************************
export { LoggerType } from "./logger-type";
33 changes: 33 additions & 0 deletions packages/common/compile/es6/src/logging/logger-type.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 定义了日志类型枚举。
*
* @export
* @enum {number}
*/
export declare enum LoggerType {
/**
* 追踪型日志。
*/
TRACE = 1,
/**
* 调试型日志。
*/
DEBUG = 2,
/**
* 信息型日志。
*/
INFO = 4,
/**
* 警告型日志。
*/
WARN = 8,
/**
* 错误型日志。
*/
ERROR = 16
}
/**
* 为 LoggerType 类型提供的扩展方法。
*/
export declare namespace LoggerType {
}
48 changes: 48 additions & 0 deletions packages/common/compile/es6/src/logging/logger-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// **************************************************************************************************************************
// COPYRIGHT © 2006 - 2022 WANG YUCAI. ALL RIGHTS RESERVED.
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION.
// **************************************************************************************************************************
/**
* 定义了日志类型枚举。
*
* @export
* @enum {number}
*/
export var LoggerType;
(function (LoggerType) {
/**
* 追踪型日志。
*/
LoggerType[LoggerType["TRACE"] = 1] = "TRACE";
/**
* 调试型日志。
*/
LoggerType[LoggerType["DEBUG"] = 2] = "DEBUG";
/**
* 信息型日志。
*/
LoggerType[LoggerType["INFO"] = 4] = "INFO";
/**
* 警告型日志。
*/
LoggerType[LoggerType["WARN"] = 8] = "WARN";
/**
* 错误型日志。
*/
LoggerType[LoggerType["ERROR"] = 16] = "ERROR";
})(LoggerType || (LoggerType = {}));
/**
* 为 LoggerType 类型提供的扩展方法。
*/
(function (LoggerType) {
/**
* 用于校验 source 是否等于 target 值。
*
* @param {(LoggerType | number)} source 需要对比的源值。
* @param {(LoggerType | number)} target 需要对比的目标值。
* @returns {boolean}
*/
function equals(source, target) {
return (source & target) === target;
}
})(LoggerType || (LoggerType = {}));
2 changes: 1 addition & 1 deletion packages/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION.
// **************************************************************************************************************************

export { sealed } from "./src";
export { sealed, LoggerType } from "./src";
3 changes: 2 additions & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION.
// **************************************************************************************************************************

export { sealed } from "./decorators";
export { sealed } from "./decorators";
export { LoggerType } from "./logging";
6 changes: 6 additions & 0 deletions packages/common/src/logging/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// **************************************************************************************************************************
// COPYRIGHT © 2006 - 2022 WANG YUCAI. ALL RIGHTS RESERVED.
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION.
// **************************************************************************************************************************

export { LoggerType } from "./logger-type";
49 changes: 49 additions & 0 deletions packages/common/src/logging/logger-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// **************************************************************************************************************************
// COPYRIGHT © 2006 - 2022 WANG YUCAI. ALL RIGHTS RESERVED.
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION.
// **************************************************************************************************************************

/**
* 定义了日志类型枚举。
*
* @export
* @enum {number}
*/
export enum LoggerType {
/**
* 追踪型日志。
*/
TRACE = 1,
/**
* 调试型日志。
*/
DEBUG = 2,
/**
* 信息型日志。
*/
INFO = 4,
/**
* 警告型日志。
*/
WARN = 8,
/**
* 错误型日志。
*/
ERROR = 16
}

/**
* 为 LoggerType 类型提供的扩展方法。
*/
export namespace LoggerType {
/**
* 用于校验 source 是否等于 target 值。
*
* @param {(LoggerType | number)} source 需要对比的源值。
* @param {(LoggerType | number)} target 需要对比的目标值。
* @returns {boolean}
*/
function equals(source: LoggerType | number, target: LoggerType | number): boolean {
return (source & target) === target;
}
}

0 comments on commit 112c376

Please sign in to comment.