@vyriy/logger 0.1.9

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vyriy contributors
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,63 @@
1
+ # @vyriy/logger
2
+
3
+ Shared logger helpers for Vyriy projects.
4
+
5
+ ## Purpose
6
+
7
+ This package exposes the raw `console` object as `logger` and a `createLogger()` helper that filters messages by `LOG_LEVEL`.
8
+
9
+ ## Install
10
+
11
+ With npm:
12
+
13
+ ```bash
14
+ npm install @vyriy/logger
15
+ ```
16
+
17
+ With Yarn:
18
+
19
+ ```bash
20
+ yarn add @vyriy/logger
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```ts
26
+ import { LOG_LEVELS, createLogger, logger } from '@vyriy/logger';
27
+
28
+ logger.log('plain console logging');
29
+
30
+ console.log(LOG_LEVELS);
31
+
32
+ const appLogger = createLogger();
33
+
34
+ appLogger.debug('debug message');
35
+ appLogger.info('info message');
36
+ appLogger.warn('warn message');
37
+ appLogger.error('error message');
38
+ ```
39
+
40
+ ## API
41
+
42
+ - `logger`
43
+ Exposes the global `console`.
44
+
45
+ - `createLogger()`
46
+ Creates a logger that respects `LOG_LEVEL`.
47
+
48
+ - `LOG_LEVELS`
49
+ Lists supported log levels from lowest to highest severity.
50
+
51
+ Supported log levels:
52
+
53
+ - `debug`
54
+ - `info`
55
+ - `warn`
56
+ - `error`
57
+
58
+ ## Notes
59
+
60
+ - `LOG_LEVEL` is read from `process.env`.
61
+ - Unknown or missing `LOG_LEVEL` falls back to `warn`.
62
+ - `debug`, `info`, `warn`, and `error` are filtered by level.
63
+ - `log()` is treated as `info()`.
package/create.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type { CreateLogger } from './types.js';
2
+ export declare const createLogger: CreateLogger;
package/create.js ADDED
@@ -0,0 +1,30 @@
1
+ import { logger } from './logger.js';
2
+ import { LOG_LEVELS } from './levels.js';
3
+ const levelWeight = {
4
+ debug: 10,
5
+ info: 20,
6
+ warn: 30,
7
+ error: 40,
8
+ };
9
+ const isLogLevel = (value) => LOG_LEVELS.includes(value);
10
+ const getLogLevel = () => {
11
+ const value = process.env.LOG_LEVEL?.trim().toLowerCase();
12
+ return value && isLogLevel(value) ? value : 'warn';
13
+ };
14
+ export const createLogger = () => {
15
+ const logLevel = getLogLevel();
16
+ const log = (level, ...messages) => {
17
+ const minWeight = levelWeight[logLevel];
18
+ if (levelWeight[level] >= minWeight) {
19
+ logger[level](...messages);
20
+ }
21
+ };
22
+ return {
23
+ ...logger,
24
+ debug: (...messages) => log('debug', ...messages),
25
+ info: (...messages) => log('info', ...messages),
26
+ log: (...messages) => log('info', ...messages),
27
+ warn: (...messages) => log('warn', ...messages),
28
+ error: (...messages) => log('error', ...messages),
29
+ };
30
+ };
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './create.js';
2
+ export * from './levels.js';
3
+ export * from './logger.js';
4
+ export type * from './types.js';
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './create.js';
2
+ export * from './levels.js';
3
+ export * from './logger.js';
package/levels.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
package/levels.js ADDED
@@ -0,0 +1,6 @@
1
+ export const LOG_LEVELS = [
2
+ 'debug',
3
+ 'info',
4
+ 'warn',
5
+ 'error',
6
+ ];
package/logger.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const logger: Console;
package/logger.js ADDED
@@ -0,0 +1 @@
1
+ export const logger = console;
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@vyriy/logger",
3
+ "version": "0.1.9",
4
+ "description": "Shared logger utility for Vyriy projects",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "license": "MIT",
8
+ "types": "./index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./index.d.ts",
12
+ "import": "./index.js",
13
+ "default": "./index.js"
14
+ },
15
+ "./create": {
16
+ "types": "./create.d.ts",
17
+ "import": "./create.js",
18
+ "default": "./create.js"
19
+ },
20
+ "./create.js": {
21
+ "types": "./create.d.ts",
22
+ "import": "./create.js",
23
+ "default": "./create.js"
24
+ },
25
+ "./index": {
26
+ "types": "./index.d.ts",
27
+ "import": "./index.js",
28
+ "default": "./index.js"
29
+ },
30
+ "./index.js": {
31
+ "types": "./index.d.ts",
32
+ "import": "./index.js",
33
+ "default": "./index.js"
34
+ },
35
+ "./levels": {
36
+ "types": "./levels.d.ts",
37
+ "import": "./levels.js",
38
+ "default": "./levels.js"
39
+ },
40
+ "./levels.js": {
41
+ "types": "./levels.d.ts",
42
+ "import": "./levels.js",
43
+ "default": "./levels.js"
44
+ },
45
+ "./logger": {
46
+ "types": "./logger.d.ts",
47
+ "import": "./logger.js",
48
+ "default": "./logger.js"
49
+ },
50
+ "./logger.js": {
51
+ "types": "./logger.d.ts",
52
+ "import": "./logger.js",
53
+ "default": "./logger.js"
54
+ }
55
+ }
56
+ }
package/types.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { LOG_LEVELS } from './levels.js';
2
+ export type LogLevel = (typeof LOG_LEVELS)[number];
3
+ export type Log = (level: LogLevel, ...messages: unknown[]) => void;
4
+ export type CreateLogger = () => Console;