@ptdlib/quicklog 1.0.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial project setup
12
+
13
+ ## [1.0.0] - YYYY-MM-DD
14
+
15
+ ### Added
16
+ - Initial release
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026, PaxtonTerryDev
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Quicklog
2
+
3
+ A minimal, color-coded logging utility for Node.js and TypeScript applications. Quicklog provides five log levels (debug, info, warn, error, fatal) with distinct color formatting via chalk, optional timestamps, and automatic suppression of debug messages in production. It requires no configuration to get started—just import and use.
4
+
5
+ To install, run `npm install @paxtonterrydev/quicklog`. Import the `log` object and call the appropriate method for your message severity. Debug messages are hidden when `NODE_ENV=production`, and calling `log.fatal()` sets `process.exitCode = 1` for graceful shutdown handling. Enable timestamps by setting `log.timestamp = true`.
6
+
7
+ ## Usage
8
+
9
+ ```typescript
10
+ import { log } from '@paxtonterrydev/quicklog';
11
+
12
+ log.debug('Only shown in development');
13
+ log.info('Application started');
14
+ log.warn('Deprecated feature used');
15
+ log.error('Failed to connect');
16
+ log.fatal('Unrecoverable error'); // Sets process.exitCode = 1
17
+
18
+ // Enable timestamps
19
+ log.timestamp = true;
20
+ log.info('Message with timestamp');
21
+
22
+ // Log objects with full depth
23
+ log.object({ nested: { data: { here: true } } });
24
+ ```
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Main logging utility object providing color-coded console output at various log levels.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { log } from '@paxtonterrydev/quicklog';
7
+ *
8
+ * log.info('Server started');
9
+ * log.warn('Deprecated API usage');
10
+ * log.error('Connection failed');
11
+ *
12
+ * // Enable timestamps
13
+ * log.timestamp = true;
14
+ * log.info('This message includes a timestamp');
15
+ * ```
16
+ */
17
+ export declare const log: Log;
18
+ /** Function signature for log level methods. */
19
+ type LogFunction = (message: string, ...args: unknown[]) => void;
20
+ /** The main log object interface. */
21
+ interface Log {
22
+ timestamp: boolean;
23
+ debug: LogFunction;
24
+ info: LogFunction;
25
+ warn: LogFunction;
26
+ error: LogFunction;
27
+ fatal: LogFunction;
28
+ object: (object: Object) => void;
29
+ }
30
+ export {};
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,GAAG,EAAE,GA2DjB,CAAA;AAED,gDAAgD;AAChD,KAAK,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAEjE,qCAAqC;AACrC,UAAU,GAAG;IACX,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC"}
package/dist/index.js ADDED
@@ -0,0 +1,124 @@
1
+ import chalk from 'chalk';
2
+ /**
3
+ * Main logging utility object providing color-coded console output at various log levels.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { log } from '@paxtonterrydev/quicklog';
8
+ *
9
+ * log.info('Server started');
10
+ * log.warn('Deprecated API usage');
11
+ * log.error('Connection failed');
12
+ *
13
+ * // Enable timestamps
14
+ * log.timestamp = true;
15
+ * log.info('This message includes a timestamp');
16
+ * ```
17
+ */
18
+ export const log = {
19
+ /**
20
+ * When true, prepends a timestamp to all log messages.
21
+ * @default false
22
+ */
23
+ timestamp: false,
24
+ /**
25
+ * Logs a debug message. Only outputs in non-production environments
26
+ * (when NODE_ENV is not set to 'production').
27
+ * @param message - The message to log
28
+ */
29
+ debug: function (message) {
30
+ if (isProduction())
31
+ return;
32
+ console.log(formatMessage({ level: "debug", message }));
33
+ },
34
+ /**
35
+ * Logs an informational message.
36
+ * @param message - The message to log
37
+ */
38
+ info: function (message) {
39
+ console.log(formatMessage({ level: "info", message }));
40
+ },
41
+ /**
42
+ * Logs a warning message.
43
+ * @param message - The message to log
44
+ */
45
+ warn: function (message) {
46
+ console.warn(formatMessage({ level: "warn", message }));
47
+ },
48
+ /**
49
+ * Logs an error message.
50
+ * @param message - The message to log
51
+ */
52
+ error: function (message) {
53
+ console.error(formatMessage({ level: "error", message }));
54
+ },
55
+ /**
56
+ * Logs a fatal error message and sets process.exitCode to 1.
57
+ * Use for unrecoverable errors that should terminate the application.
58
+ * @param message - The message to log
59
+ */
60
+ fatal: function (message) {
61
+ console.error(formatMessage({ level: "fatal", message }));
62
+ process.exitCode = 1;
63
+ },
64
+ /**
65
+ * Logs an object with full depth inspection.
66
+ * Useful for debugging complex nested objects.
67
+ * @param object - The object to log
68
+ */
69
+ object: (object) => {
70
+ console.dir(object, { depth: null });
71
+ }
72
+ };
73
+ /** Color mappings for each log level. */
74
+ const colors = {
75
+ debug: {
76
+ level: chalk.green,
77
+ message: chalk.white,
78
+ },
79
+ info: {
80
+ level: chalk.blue,
81
+ message: chalk.white,
82
+ },
83
+ warn: {
84
+ level: chalk.yellow,
85
+ message: chalk.yellow,
86
+ },
87
+ error: {
88
+ level: chalk.red,
89
+ message: chalk.red,
90
+ },
91
+ fatal: {
92
+ level: chalk.bgRedBright,
93
+ message: chalk.bgRedBright,
94
+ },
95
+ };
96
+ /**
97
+ * Formats a log message with colors and optional timestamp.
98
+ * @param msg - The log message configuration
99
+ * @returns The formatted, colorized string ready for output
100
+ */
101
+ function formatMessage(msg) {
102
+ const levelColor = colors[msg.level].level;
103
+ const messageColor = colors[msg.level].message;
104
+ const levelStr = `[${msg.level.toUpperCase()}]`;
105
+ return `${log.timestamp ? `${createTimestamp()} ` : ""}${levelColor(levelStr.padEnd(7, " "))} ${messageColor(msg.message)}`;
106
+ }
107
+ /**
108
+ * Creates a formatted timestamp string using the local date and time.
109
+ * @returns A timestamp in the format "[MM/DD/YYYY HH:MM:SS AM/PM]"
110
+ */
111
+ function createTimestamp() {
112
+ const now = new Date();
113
+ const localDate = now.toLocaleDateString();
114
+ const localTime = now.toLocaleTimeString();
115
+ return `[${localDate} ${localTime}]`;
116
+ }
117
+ /**
118
+ * Checks if the current environment is production.
119
+ * @returns True if NODE_ENV is set to 'production'
120
+ */
121
+ function isProduction() {
122
+ return process.env.NODE_ENV === 'production';
123
+ }
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":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I,SAAS,GAAG,CAAA;AACtC,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY;IACnB,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAC/C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@ptdlib/quicklog",
3
+ "version": "1.0.2",
4
+ "description": "Simple logging utility for typescript",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE",
19
+ "CHANGELOG.md"
20
+ ],
21
+ "scripts": {
22
+ "dev": "tsx --watch src/index.ts",
23
+ "build": "tsc",
24
+ "prepare": "npm run build",
25
+ "pub": "npm publish --access=public"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/PaxtonTerryDev/quicklog.git"
30
+ },
31
+ "author": "PaxtonTerryDev",
32
+ "license": "ISC",
33
+ "bugs": {
34
+ "url": "https://github.com/PaxtonTerryDev/quicklog/issues"
35
+ },
36
+ "homepage": "https://github.com/PaxtonTerryDev/quicklog#readme",
37
+ "devDependencies": {
38
+ "@types/node": "^25.0.9",
39
+ "tsx": "^4.21.0",
40
+ "typescript": "^5.9.3"
41
+ },
42
+ "dependencies": {
43
+ "chalk": "^5.6.2",
44
+ "dotenv": "^17.2.3"
45
+ }
46
+ }