@feizk/logger 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +42 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +35 -0
- package/src/index.ts +46 -0
- package/tests/logger.test.ts +65 -0
- package/tsup.config.ts +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Feizk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @feizk/logger
|
|
2
|
+
|
|
3
|
+
A simple logger package with colored outputs and timestamps.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @feizk/logger
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Logger } from '@feizk/logger';
|
|
15
|
+
|
|
16
|
+
const logger = new Logger();
|
|
17
|
+
|
|
18
|
+
logger.info('This is an info message');
|
|
19
|
+
logger.warn('This is a warning');
|
|
20
|
+
logger.error('This is an error');
|
|
21
|
+
logger.debug('This is a debug message');
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
### Logger
|
|
27
|
+
|
|
28
|
+
- `info(message: string)`: Logs an info message.
|
|
29
|
+
- `warn(message: string)`: Logs a warning message.
|
|
30
|
+
- `error(message: string)`: Logs an error message.
|
|
31
|
+
- `debug(message: string)`: Logs a debug message.
|
|
32
|
+
|
|
33
|
+
All messages include a timestamp and are colored accordingly.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple logger with colored outputs and timestamps.
|
|
3
|
+
*/
|
|
4
|
+
declare class Logger {
|
|
5
|
+
/**
|
|
6
|
+
* Logs an info message.
|
|
7
|
+
* @param message - The message to log.
|
|
8
|
+
*/
|
|
9
|
+
info(message: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Logs a warning message.
|
|
12
|
+
* @param message - The message to log.
|
|
13
|
+
*/
|
|
14
|
+
warn(message: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Logs an error message.
|
|
17
|
+
* @param message - The message to log.
|
|
18
|
+
*/
|
|
19
|
+
error(message: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Logs a debug message.
|
|
22
|
+
* @param message - The message to log.
|
|
23
|
+
*/
|
|
24
|
+
debug(message: string): void;
|
|
25
|
+
private getTimestamp;
|
|
26
|
+
private removeFunction;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { Logger };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple logger with colored outputs and timestamps.
|
|
3
|
+
*/
|
|
4
|
+
declare class Logger {
|
|
5
|
+
/**
|
|
6
|
+
* Logs an info message.
|
|
7
|
+
* @param message - The message to log.
|
|
8
|
+
*/
|
|
9
|
+
info(message: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Logs a warning message.
|
|
12
|
+
* @param message - The message to log.
|
|
13
|
+
*/
|
|
14
|
+
warn(message: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Logs an error message.
|
|
17
|
+
* @param message - The message to log.
|
|
18
|
+
*/
|
|
19
|
+
error(message: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Logs a debug message.
|
|
22
|
+
* @param message - The message to log.
|
|
23
|
+
*/
|
|
24
|
+
debug(message: string): void;
|
|
25
|
+
private getTimestamp;
|
|
26
|
+
private removeFunction;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { Logger };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Logger: () => Logger
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_chalk = __toESM(require("chalk"));
|
|
37
|
+
var Logger = class {
|
|
38
|
+
/**
|
|
39
|
+
* Logs an info message.
|
|
40
|
+
* @param message - The message to log.
|
|
41
|
+
*/
|
|
42
|
+
info(message) {
|
|
43
|
+
console.log(`${import_chalk.default.blue("[INFO]")} ${this.getTimestamp()} ${message}`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Logs a warning message.
|
|
47
|
+
* @param message - The message to log.
|
|
48
|
+
*/
|
|
49
|
+
warn(message) {
|
|
50
|
+
console.log(`${import_chalk.default.yellow("[WARN]")} ${this.getTimestamp()} ${message}`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Logs an error message.
|
|
54
|
+
* @param message - The message to log.
|
|
55
|
+
*/
|
|
56
|
+
error(message) {
|
|
57
|
+
console.log(`${import_chalk.default.red("[ERROR]")} ${this.getTimestamp()} ${message}`);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Logs a debug message.
|
|
61
|
+
* @param message - The message to log.
|
|
62
|
+
*/
|
|
63
|
+
debug(message) {
|
|
64
|
+
console.log(`${import_chalk.default.gray("[DEBUG]")} ${this.getTimestamp()} ${message}`);
|
|
65
|
+
}
|
|
66
|
+
getTimestamp() {
|
|
67
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
68
|
+
}
|
|
69
|
+
removeFunction() {
|
|
70
|
+
return "Please remove this function";
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
Logger
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import chalk from 'chalk';\n\n/**\n * A simple logger with colored outputs and timestamps.\n */\nexport class Logger {\n /**\n * Logs an info message.\n * @param message - The message to log.\n */\n info(message: string): void {\n console.log(`${chalk.blue('[INFO]')} ${this.getTimestamp()} ${message}`);\n }\n\n /**\n * Logs a warning message.\n * @param message - The message to log.\n */\n warn(message: string): void {\n console.log(`${chalk.yellow('[WARN]')} ${this.getTimestamp()} ${message}`);\n }\n\n /**\n * Logs an error message.\n * @param message - The message to log.\n */\n error(message: string): void {\n console.log(`${chalk.red('[ERROR]')} ${this.getTimestamp()} ${message}`);\n }\n\n /**\n * Logs a debug message.\n * @param message - The message to log.\n */\n debug(message: string): void {\n console.log(`${chalk.gray('[DEBUG]')} ${this.getTimestamp()} ${message}`);\n }\n\n private getTimestamp(): string {\n return new Date().toISOString();\n }\n\n private removeFunction() {\n return 'Please remove this function';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAKX,IAAM,SAAN,MAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlB,KAAK,SAAuB;AAC1B,YAAQ,IAAI,GAAG,aAAAA,QAAM,KAAK,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,OAAO,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAK,SAAuB;AAC1B,YAAQ,IAAI,GAAG,aAAAA,QAAM,OAAO,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,OAAO,EAAE;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,SAAuB;AAC3B,YAAQ,IAAI,GAAG,aAAAA,QAAM,IAAI,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,OAAO,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,SAAuB;AAC3B,YAAQ,IAAI,GAAG,aAAAA,QAAM,KAAK,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,OAAO,EAAE;AAAA,EAC1E;AAAA,EAEQ,eAAuB;AAC7B,YAAO,oBAAI,KAAK,GAAE,YAAY;AAAA,EAChC;AAAA,EAEQ,iBAAiB;AACvB,WAAO;AAAA,EACT;AACF;","names":["chalk"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
var Logger = class {
|
|
4
|
+
/**
|
|
5
|
+
* Logs an info message.
|
|
6
|
+
* @param message - The message to log.
|
|
7
|
+
*/
|
|
8
|
+
info(message) {
|
|
9
|
+
console.log(`${chalk.blue("[INFO]")} ${this.getTimestamp()} ${message}`);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Logs a warning message.
|
|
13
|
+
* @param message - The message to log.
|
|
14
|
+
*/
|
|
15
|
+
warn(message) {
|
|
16
|
+
console.log(`${chalk.yellow("[WARN]")} ${this.getTimestamp()} ${message}`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Logs an error message.
|
|
20
|
+
* @param message - The message to log.
|
|
21
|
+
*/
|
|
22
|
+
error(message) {
|
|
23
|
+
console.log(`${chalk.red("[ERROR]")} ${this.getTimestamp()} ${message}`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Logs a debug message.
|
|
27
|
+
* @param message - The message to log.
|
|
28
|
+
*/
|
|
29
|
+
debug(message) {
|
|
30
|
+
console.log(`${chalk.gray("[DEBUG]")} ${this.getTimestamp()} ${message}`);
|
|
31
|
+
}
|
|
32
|
+
getTimestamp() {
|
|
33
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
34
|
+
}
|
|
35
|
+
removeFunction() {
|
|
36
|
+
return "Please remove this function";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
Logger
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import chalk from 'chalk';\n\n/**\n * A simple logger with colored outputs and timestamps.\n */\nexport class Logger {\n /**\n * Logs an info message.\n * @param message - The message to log.\n */\n info(message: string): void {\n console.log(`${chalk.blue('[INFO]')} ${this.getTimestamp()} ${message}`);\n }\n\n /**\n * Logs a warning message.\n * @param message - The message to log.\n */\n warn(message: string): void {\n console.log(`${chalk.yellow('[WARN]')} ${this.getTimestamp()} ${message}`);\n }\n\n /**\n * Logs an error message.\n * @param message - The message to log.\n */\n error(message: string): void {\n console.log(`${chalk.red('[ERROR]')} ${this.getTimestamp()} ${message}`);\n }\n\n /**\n * Logs a debug message.\n * @param message - The message to log.\n */\n debug(message: string): void {\n console.log(`${chalk.gray('[DEBUG]')} ${this.getTimestamp()} ${message}`);\n }\n\n private getTimestamp(): string {\n return new Date().toISOString();\n }\n\n private removeFunction() {\n return 'Please remove this function';\n }\n}\n"],"mappings":";AAAA,OAAO,WAAW;AAKX,IAAM,SAAN,MAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlB,KAAK,SAAuB;AAC1B,YAAQ,IAAI,GAAG,MAAM,KAAK,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,OAAO,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAK,SAAuB;AAC1B,YAAQ,IAAI,GAAG,MAAM,OAAO,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,OAAO,EAAE;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,SAAuB;AAC3B,YAAQ,IAAI,GAAG,MAAM,IAAI,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,OAAO,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,SAAuB;AAC3B,YAAQ,IAAI,GAAG,MAAM,KAAK,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,OAAO,EAAE;AAAA,EAC1E;AAAA,EAEQ,eAAuB;AAC7B,YAAO,oBAAI,KAAK,GAAE,YAAY;AAAA,EAChC;AAAA,EAEQ,iBAAiB;AACvB,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@feizk/logger",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A simple logger package with colored outputs and timestamps",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"chalk": "^5.3.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/node": "^20.0.0",
|
|
15
|
+
"vitest": "^1.6.1"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"logger",
|
|
19
|
+
"console",
|
|
20
|
+
"colors",
|
|
21
|
+
"timestamps"
|
|
22
|
+
],
|
|
23
|
+
"author": "feizk",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"tsc": "tsc",
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"lint": "eslint src",
|
|
31
|
+
"lint:fix": "eslint src --fix",
|
|
32
|
+
"test": "vitest",
|
|
33
|
+
"test:run": "vitest run"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A simple logger with colored outputs and timestamps.
|
|
5
|
+
*/
|
|
6
|
+
export class Logger {
|
|
7
|
+
/**
|
|
8
|
+
* Logs an info message.
|
|
9
|
+
* @param message - The message to log.
|
|
10
|
+
*/
|
|
11
|
+
info(message: string): void {
|
|
12
|
+
console.log(`${chalk.blue('[INFO]')} ${this.getTimestamp()} ${message}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Logs a warning message.
|
|
17
|
+
* @param message - The message to log.
|
|
18
|
+
*/
|
|
19
|
+
warn(message: string): void {
|
|
20
|
+
console.log(`${chalk.yellow('[WARN]')} ${this.getTimestamp()} ${message}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Logs an error message.
|
|
25
|
+
* @param message - The message to log.
|
|
26
|
+
*/
|
|
27
|
+
error(message: string): void {
|
|
28
|
+
console.log(`${chalk.red('[ERROR]')} ${this.getTimestamp()} ${message}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Logs a debug message.
|
|
33
|
+
* @param message - The message to log.
|
|
34
|
+
*/
|
|
35
|
+
debug(message: string): void {
|
|
36
|
+
console.log(`${chalk.gray('[DEBUG]')} ${this.getTimestamp()} ${message}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private getTimestamp(): string {
|
|
40
|
+
return new Date().toISOString();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private removeFunction() {
|
|
44
|
+
return 'Please remove this function';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
it,
|
|
4
|
+
expect,
|
|
5
|
+
vi,
|
|
6
|
+
beforeEach,
|
|
7
|
+
afterEach,
|
|
8
|
+
type MockInstance,
|
|
9
|
+
} from 'vitest';
|
|
10
|
+
import { Logger } from '../src/index';
|
|
11
|
+
|
|
12
|
+
describe('Logger', () => {
|
|
13
|
+
let logger: Logger;
|
|
14
|
+
let consoleSpy: MockInstance<
|
|
15
|
+
[message?: unknown, ...optionalParams: unknown[]],
|
|
16
|
+
void
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
logger = new Logger();
|
|
21
|
+
consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
consoleSpy.mockRestore();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should have info method', () => {
|
|
29
|
+
logger.info('test message');
|
|
30
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('[INFO]'));
|
|
31
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
32
|
+
expect.stringContaining('test message'),
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should have warn method', () => {
|
|
37
|
+
logger.warn('test message');
|
|
38
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('[WARN]'));
|
|
39
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
40
|
+
expect.stringContaining('test message'),
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should have error method', () => {
|
|
45
|
+
logger.error('test message');
|
|
46
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('[ERROR]'));
|
|
47
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
48
|
+
expect.stringContaining('test message'),
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should have debug method', () => {
|
|
53
|
+
logger.debug('test message');
|
|
54
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('[DEBUG]'));
|
|
55
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
56
|
+
expect.stringContaining('test message'),
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should include timestamp in logs', () => {
|
|
61
|
+
logger.info('test');
|
|
62
|
+
const callArgs = consoleSpy.mock.calls[0][0];
|
|
63
|
+
expect(callArgs).toMatch(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/);
|
|
64
|
+
});
|
|
65
|
+
});
|