@linaria/logger
Advanced tools
Comparing version 4.5.0 to 5.0.0
import genericDebug from 'debug'; | ||
import pc from 'picocolors'; | ||
const levels = ['error', 'warn', 'info', 'debug']; | ||
const currentLevel = levels.indexOf(process.env.LINARIA_LOG || 'warn'); | ||
const linariaLogger = genericDebug('linaria'); | ||
export const linariaLogger = genericDebug('linaria'); | ||
const loggers = new Map(); | ||
@@ -16,5 +14,6 @@ function gerOrCreate(namespace) { | ||
genericDebug.formatters.r = ref => { | ||
const color = parseInt(gerOrCreate(ref.namespace).color, 10); | ||
const namespace = typeof ref === 'string' ? ref : ref.namespace; | ||
const text = typeof ref === 'string' ? namespace : ref.text ?? namespace; | ||
const color = parseInt(gerOrCreate(namespace).color, 10); | ||
const colorCode = `\u001B[3${color < 8 ? color : `8;5;${color}`}`; | ||
const text = ref.text ?? ref.namespace; | ||
return `${colorCode};1m${text}\u001B[0m`; | ||
@@ -31,6 +30,6 @@ }; | ||
}; | ||
function log(level, namespaces, template, ...restArgs) { | ||
if (currentLevel < levels.indexOf(level)) { | ||
return; | ||
} | ||
export function enableDebug(namespace = 'linaria:*') { | ||
genericDebug.enable(namespace); | ||
} | ||
export function debug(namespaces, template, ...restArgs) { | ||
const logger = gerOrCreate(namespaces); | ||
@@ -47,6 +46,2 @@ if (!logger.enabled) return; | ||
} | ||
export const debug = log.bind(null, 'debug'); | ||
export const info = log.bind(null, 'info'); | ||
export const warn = log.bind(null, 'warn'); | ||
export const error = log.bind(null, 'error'); | ||
export const notify = message => { | ||
@@ -53,0 +48,0 @@ // eslint-disable-next-line no-console |
@@ -7,9 +7,10 @@ "use strict"; | ||
exports.createCustomDebug = createCustomDebug; | ||
exports.warn = exports.notify = exports.info = exports.error = exports.debug = void 0; | ||
exports.debug = debug; | ||
exports.enableDebug = enableDebug; | ||
exports.notify = exports.linariaLogger = void 0; | ||
var _debug = _interopRequireDefault(require("debug")); | ||
var _picocolors = _interopRequireDefault(require("picocolors")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const levels = ['error', 'warn', 'info', 'debug']; | ||
const currentLevel = levels.indexOf(process.env.LINARIA_LOG || 'warn'); | ||
const linariaLogger = (0, _debug.default)('linaria'); | ||
exports.linariaLogger = linariaLogger; | ||
const loggers = new Map(); | ||
@@ -26,5 +27,6 @@ function gerOrCreate(namespace) { | ||
var _ref$text; | ||
const color = parseInt(gerOrCreate(ref.namespace).color, 10); | ||
const namespace = typeof ref === 'string' ? ref : ref.namespace; | ||
const text = typeof ref === 'string' ? namespace : (_ref$text = ref.text) !== null && _ref$text !== void 0 ? _ref$text : namespace; | ||
const color = parseInt(gerOrCreate(namespace).color, 10); | ||
const colorCode = `\u001B[3${color < 8 ? color : `8;5;${color}`}`; | ||
const text = (_ref$text = ref.text) !== null && _ref$text !== void 0 ? _ref$text : ref.namespace; | ||
return `${colorCode};1m${text}\u001B[0m`; | ||
@@ -41,6 +43,6 @@ }; | ||
}; | ||
function log(level, namespaces, template, ...restArgs) { | ||
if (currentLevel < levels.indexOf(level)) { | ||
return; | ||
} | ||
function enableDebug(namespace = 'linaria:*') { | ||
_debug.default.enable(namespace); | ||
} | ||
function debug(namespaces, template, ...restArgs) { | ||
const logger = gerOrCreate(namespaces); | ||
@@ -57,10 +59,2 @@ if (!logger.enabled) return; | ||
} | ||
const debug = log.bind(null, 'debug'); | ||
exports.debug = debug; | ||
const info = log.bind(null, 'info'); | ||
exports.info = info; | ||
const warn = log.bind(null, 'warn'); | ||
exports.warn = warn; | ||
const error = log.bind(null, 'error'); | ||
exports.error = error; | ||
const notify = message => { | ||
@@ -67,0 +61,0 @@ // eslint-disable-next-line no-console |
{ | ||
"name": "@linaria/logger", | ||
"version": "4.5.0", | ||
"version": "5.0.0", | ||
"description": "Blazing fast zero-runtime CSS in JS library", | ||
@@ -25,11 +25,11 @@ "keywords": [ | ||
"dependencies": { | ||
"debug": "^4.1.1", | ||
"debug": "^4.3.4", | ||
"picocolors": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "^4.1.5", | ||
"@types/debug": "^4.1.8", | ||
"@types/node": "^17.0.39" | ||
}, | ||
"engines": { | ||
"node": "^12.16.0 || >=13.7.0" | ||
"node": ">=16.0.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "publishConfig": { |
@@ -1,7 +0,9 @@ | ||
export declare const debug: (namespaces: string, template: unknown, ...restArgs: unknown[]) => void; | ||
export declare const info: (namespaces: string, template: unknown, ...restArgs: unknown[]) => void; | ||
export declare const warn: (namespaces: string, template: unknown, ...restArgs: unknown[]) => void; | ||
export declare const error: (namespaces: string, template: unknown, ...restArgs: unknown[]) => void; | ||
import genericDebug from 'debug'; | ||
import type { Debugger } from 'debug'; | ||
export type { Debugger }; | ||
export declare const linariaLogger: genericDebug.Debugger; | ||
export declare function enableDebug(namespace?: string): void; | ||
export declare function debug(namespaces: string, template: unknown | (() => void), ...restArgs: unknown[]): void; | ||
export declare const notify: (message: string) => void; | ||
export declare type CustomDebug = (namespace: string, template: string, ...args: unknown[]) => void; | ||
export type CustomDebug = (namespace: string, template: string, ...args: unknown[]) => void; | ||
export declare function createCustomDebug(name: string, id: number): CustomDebug; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1
19742
129
Updateddebug@^4.3.4