exa-logger
Advanced tools
Comparing version 1.0.8 to 1.0.9
type LogLevel = 'INFO' | 'WARN' | 'ERROR'; | ||
declare const _default: { | ||
@@ -24,2 +25,3 @@ log: (level: LogLevel, ...messages: any) => { | ||
}; | ||
export default _default; | ||
export { _default as default }; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dayjs_1 = __importDefault(require("dayjs")); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const log = (level, ...messages) => { | ||
const logData = []; | ||
const date = (0, dayjs_1.default)().format('YYYY-MM-DD HH:mm:ss'); | ||
logData.push(`[${chalk_1.default.gray(date)}]`); | ||
switch (level) { | ||
case 'INFO': | ||
logData.push(`${chalk_1.default.blue.bold(level)}`); | ||
break; | ||
case 'WARN': | ||
logData.push(`${chalk_1.default.yellow.bold(level)}`); | ||
break; | ||
case 'ERROR': | ||
logData.push(`${chalk_1.default.red.bold(level)}`); | ||
break; | ||
default: | ||
logData.push(`${chalk_1.default.blue.bold(level)}`); | ||
break; | ||
} | ||
logData.push(":"); | ||
logData.push(...messages); | ||
console.log(...logData); | ||
// Return an object to allow chaining | ||
return { | ||
info: (...msgs) => log('INFO', ...msgs), | ||
warn: (...msgs) => log('WARN', ...msgs), | ||
error: (...msgs) => log('ERROR', ...msgs), | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
const info = (...messages) => log('INFO', ...messages); | ||
const warn = (...messages) => log('WARN', ...messages); | ||
const error = (...messages) => log('ERROR', ...messages); | ||
exports.default = { | ||
log, | ||
info, | ||
warn, | ||
error, | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
default: () => src_default | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var import_dayjs = __toESM(require("dayjs")); | ||
var import_chalk = __toESM(require("chalk")); | ||
var log = (level, ...messages) => { | ||
const logData = []; | ||
const date = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"); | ||
logData.push(`[${import_chalk.default.gray(date)}]`); | ||
switch (level) { | ||
case "INFO": | ||
logData.push(`${import_chalk.default.blue.bold(level)}`); | ||
break; | ||
case "WARN": | ||
logData.push(`${import_chalk.default.yellow.bold(level)}`); | ||
break; | ||
case "ERROR": | ||
logData.push(`${import_chalk.default.red.bold(level)}`); | ||
break; | ||
default: | ||
logData.push(`${import_chalk.default.blue.bold(level)}`); | ||
break; | ||
} | ||
logData.push(":"); | ||
logData.push(...messages); | ||
console.log(...logData); | ||
return { | ||
info: (...msgs) => log("INFO", ...msgs), | ||
warn: (...msgs) => log("WARN", ...msgs), | ||
error: (...msgs) => log("ERROR", ...msgs) | ||
}; | ||
}; | ||
var info = (...messages) => log("INFO", ...messages); | ||
var warn = (...messages) => log("WARN", ...messages); | ||
var error = (...messages) => log("ERROR", ...messages); | ||
var src_default = { | ||
log, | ||
info, | ||
warn, | ||
error | ||
}; |
{ | ||
"name": "exa-logger", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Advanced JavaScript logger for debugging.", | ||
"main": "dist/index.js", | ||
"types": "types/types.d.ts", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "npx tsc", | ||
"build": "tsup src/index.ts --format cjs,esm --dts", | ||
"prepublishOnly": "npm run build", | ||
@@ -19,2 +20,4 @@ "test": "echo \"Error: no test specified\" && exit 1" | ||
"devDependencies": { | ||
"@changesets/cli": "^2.27.7", | ||
"tsup": "^8.2.4", | ||
"typescript": "^5.5.4" | ||
@@ -26,2 +29,2 @@ }, | ||
} | ||
} | ||
} |
import dayjs from 'dayjs'; | ||
import { LogLevel } from './../types/types.d'; | ||
import chalk from 'chalk'; | ||
type LogLevel = 'INFO' | 'WARN' | 'ERROR'; | ||
const log = (level: LogLevel, ...messages: any) => { | ||
@@ -7,0 +6,0 @@ const logData = []; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20009
12
295
3