@rdrudra99/hardlog 0.1.0 → 0.1.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/dist/env.d.ts +1 -1
- package/dist/env.js +5 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -9
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +4 -7
- package/dist/types.js +1 -2
- package/package.json +1 -1
package/dist/env.d.ts
CHANGED
package/dist/env.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isBrowser = isBrowser;
|
|
4
|
-
exports.isNode = isNode;
|
|
5
|
-
exports.detectEnvironment = detectEnvironment;
|
|
6
|
-
exports.isProduction = isProduction;
|
|
7
|
-
exports.shouldLogByDefault = shouldLogByDefault;
|
|
8
1
|
/**
|
|
9
2
|
* Safely detect if we're in a browser environment
|
|
10
3
|
*/
|
|
11
|
-
function isBrowser() {
|
|
4
|
+
export function isBrowser() {
|
|
12
5
|
try {
|
|
13
6
|
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
14
7
|
}
|
|
@@ -19,7 +12,7 @@ function isBrowser() {
|
|
|
19
12
|
/**
|
|
20
13
|
* Safely detect if we're in a Node.js environment
|
|
21
14
|
*/
|
|
22
|
-
function isNode() {
|
|
15
|
+
export function isNode() {
|
|
23
16
|
try {
|
|
24
17
|
return (typeof process !== 'undefined' &&
|
|
25
18
|
process.versions != null &&
|
|
@@ -32,7 +25,7 @@ function isNode() {
|
|
|
32
25
|
/**
|
|
33
26
|
* Detect the current runtime environment
|
|
34
27
|
*/
|
|
35
|
-
function detectEnvironment() {
|
|
28
|
+
export function detectEnvironment() {
|
|
36
29
|
try {
|
|
37
30
|
if (isBrowser()) {
|
|
38
31
|
return 'browser';
|
|
@@ -49,7 +42,7 @@ function detectEnvironment() {
|
|
|
49
42
|
/**
|
|
50
43
|
* Check if we're in production mode
|
|
51
44
|
*/
|
|
52
|
-
function isProduction() {
|
|
45
|
+
export function isProduction() {
|
|
53
46
|
try {
|
|
54
47
|
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV) {
|
|
55
48
|
return process.env.NODE_ENV === 'production';
|
|
@@ -63,6 +56,6 @@ function isProduction() {
|
|
|
63
56
|
/**
|
|
64
57
|
* Check if logging should be enabled by default
|
|
65
58
|
*/
|
|
66
|
-
function shouldLogByDefault() {
|
|
59
|
+
export function shouldLogByDefault() {
|
|
67
60
|
return !isProduction();
|
|
68
61
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const logger_1 = require("./logger");
|
|
1
|
+
import { logger } from './logger.js';
|
|
4
2
|
/**
|
|
5
3
|
* Dev-only logger with beautiful, colorful output
|
|
6
4
|
*
|
|
@@ -29,25 +27,25 @@ const log = {
|
|
|
29
27
|
/**
|
|
30
28
|
* Log a success message
|
|
31
29
|
*/
|
|
32
|
-
success: (message) =>
|
|
30
|
+
success: (message) => logger.success(message),
|
|
33
31
|
/**
|
|
34
32
|
* Log an error message
|
|
35
33
|
*/
|
|
36
|
-
error: (message) =>
|
|
34
|
+
error: (message) => logger.error(message),
|
|
37
35
|
/**
|
|
38
36
|
* Log a warning message
|
|
39
37
|
*/
|
|
40
|
-
warn: (message) =>
|
|
38
|
+
warn: (message) => logger.warn(message),
|
|
41
39
|
/**
|
|
42
40
|
* Log an info message
|
|
43
41
|
*/
|
|
44
|
-
info: (message) =>
|
|
42
|
+
info: (message) => logger.info(message),
|
|
45
43
|
/**
|
|
46
44
|
* Configure logger options
|
|
47
45
|
*/
|
|
48
46
|
config: (options) => {
|
|
49
|
-
|
|
47
|
+
logger.configure(options);
|
|
50
48
|
return log;
|
|
51
49
|
},
|
|
52
50
|
};
|
|
53
|
-
|
|
51
|
+
export default log;
|
package/dist/logger.d.ts
CHANGED
package/dist/logger.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logger = void 0;
|
|
4
|
-
const env_1 = require("./env");
|
|
1
|
+
import { detectEnvironment, shouldLogByDefault } from './env.js';
|
|
5
2
|
/**
|
|
6
3
|
* ANSI color codes for Node.js terminal
|
|
7
4
|
*/
|
|
@@ -36,9 +33,9 @@ const LOG_CONFIG = {
|
|
|
36
33
|
*/
|
|
37
34
|
class Logger {
|
|
38
35
|
constructor() {
|
|
39
|
-
this.runtime =
|
|
36
|
+
this.runtime = detectEnvironment();
|
|
40
37
|
this.config = {
|
|
41
|
-
enabled:
|
|
38
|
+
enabled: shouldLogByDefault(),
|
|
42
39
|
showTimestamp: false,
|
|
43
40
|
};
|
|
44
41
|
}
|
|
@@ -153,4 +150,4 @@ class Logger {
|
|
|
153
150
|
/**
|
|
154
151
|
* Singleton logger instance
|
|
155
152
|
*/
|
|
156
|
-
|
|
153
|
+
export const logger = new Logger();
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/package.json
CHANGED