@wlix/logger 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -4,21 +4,21 @@ A tiny file-based logger for Node.js projects. It writes logs to daily files and
4
4
 
5
5
  ## How it works
6
6
 
7
- - When you create a `Logger`, it ensures the logs directory exists.
8
- - Each day gets its own log file named `DD-MM-YYYY.log`.
9
- - Every log line includes UTC time (or UTC offset), log level, and your message.
10
- - Logs are then written to the file automatically.
7
+ - When you create a logger instance, it makes sure the logs directory exists.
8
+ - Each calendar day gets its own log file named `DD-MM-YYYY.log`.
9
+ - Every log line has UTC time (or UTC offset), log type (info, warn, or error), and message.
10
+ - Logs are then written to the appropriate log file.
11
11
 
12
12
  ## Usage
13
13
 
14
- - Instantiate a new Logger instance.
14
+ - Use `createLogger()` to create a new logger.
15
15
  - Use the returned function with `"info" | "warn" | "error"` and your message.
16
16
  - Files are written to the `./logs` dir by default.
17
17
 
18
18
  ```ts
19
- import { Logger } from "./Logger";
19
+ import { createLogger } from "./Logger";
20
20
 
21
- const logger = Logger();
21
+ const logger = createLogger();
22
22
 
23
23
  logger("info", "Connected to server");
24
24
  logger("warn", "Memory is low");
package/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export type Timezone = "UTC" | `UTC${"" | "+" | "-"}${number}`;
2
-
3
2
  export interface LoggerConfig {
4
3
  /**
5
4
  * Path of the directory with log files.
@@ -28,6 +27,6 @@ export interface LoggerConfig {
28
27
  * @param config Optional logger configuration.
29
28
  * @returns A function to log messages: log(type, message)
30
29
  */
31
- export declare function Logger(
30
+ export declare function createLogger(
32
31
  config?: LoggerConfig
33
32
  ): (type: "info" | "warn" | "error", message: string) => void;
package/index.js CHANGED
@@ -14,7 +14,7 @@ const { join } = require("path");
14
14
  * @param {LoggerConfig} config Optional logger configuration.
15
15
  * @returns {(type: "info" | "warn" | "error", message: string) => void} Function to log messages
16
16
  */
17
- function Logger(config = {}) {
17
+ function createLogger(config = {}) {
18
18
  const logsPath = config.logsPath ?? "./logs";
19
19
  const logToStdout = config.logToStdout ?? true;
20
20
  const timezone = config.timezone ?? "UTC";
@@ -73,4 +73,4 @@ function Logger(config = {}) {
73
73
  return log;
74
74
  }
75
75
 
76
- module.exports = { Logger };
76
+ module.exports = { createLogger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wlix/logger",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A simple logger.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "author": "wlix",
17
- "license": "ISC",
17
+ "license": "MIT",
18
18
  "scripts": {
19
19
  "test": "echo \"Error: no test specified\" && exit 1"
20
20
  }