@linaria/logger
Advanced tools
Comparing version 3.0.0-beta.20 to 4.0.0-beta.0
@@ -19,2 +19,13 @@ import genericDebug from 'debug'; | ||
genericDebug.formatters.r = ref => { | ||
const color = parseInt(gerOrCreate(ref.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`; | ||
}; | ||
genericDebug.formatters.f = function f(fn) { | ||
return JSON.stringify(fn()); | ||
}; | ||
const format = text => { | ||
@@ -28,3 +39,3 @@ if (typeof text === 'string') { | ||
function log(level, namespaces, arg1, ...restArgs) { | ||
function log(level, namespaces, template, ...restArgs) { | ||
if (currentLevel < levels.indexOf(level)) { | ||
@@ -37,7 +48,7 @@ return; | ||
if (typeof arg1 === 'function') { | ||
const text = arg1(); | ||
if (typeof template === 'function') { | ||
const text = template(); | ||
if (text) { | ||
logger('', format(text), ...restArgs); | ||
logger(format(text), ...restArgs); | ||
} | ||
@@ -48,3 +59,3 @@ | ||
logger('', format(arg1), ...restArgs); | ||
logger(format(template), ...restArgs); | ||
} | ||
@@ -60,2 +71,11 @@ | ||
}; | ||
const padStart = (num, len) => num.toString(10).padStart(len, '0'); | ||
export function createCustomDebug(name, id) { | ||
return (..._args) => { | ||
const [namespace, arg1, ...args] = _args; | ||
debug(`${name}:${padStart(id, 5)}`, `[${namespace}] ${arg1}`, ...args); | ||
}; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.createCustomDebug = createCustomDebug; | ||
exports.warn = exports.notify = exports.info = exports.error = exports.debug = void 0; | ||
@@ -31,2 +32,15 @@ | ||
_debug.default.formatters.r = ref => { | ||
var _ref$text; | ||
const color = parseInt(gerOrCreate(ref.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`; | ||
}; | ||
_debug.default.formatters.f = function f(fn) { | ||
return JSON.stringify(fn()); | ||
}; | ||
const format = text => { | ||
@@ -40,3 +54,3 @@ if (typeof text === 'string') { | ||
function log(level, namespaces, arg1, ...restArgs) { | ||
function log(level, namespaces, template, ...restArgs) { | ||
if (currentLevel < levels.indexOf(level)) { | ||
@@ -49,7 +63,7 @@ return; | ||
if (typeof arg1 === 'function') { | ||
const text = arg1(); | ||
if (typeof template === 'function') { | ||
const text = template(); | ||
if (text) { | ||
logger('', format(text), ...restArgs); | ||
logger(format(text), ...restArgs); | ||
} | ||
@@ -60,3 +74,3 @@ | ||
logger('', format(arg1), ...restArgs); | ||
logger(format(template), ...restArgs); | ||
} | ||
@@ -79,2 +93,11 @@ | ||
exports.notify = notify; | ||
const padStart = (num, len) => num.toString(10).padStart(len, '0'); | ||
function createCustomDebug(name, id) { | ||
return (..._args) => { | ||
const [namespace, arg1, ...args] = _args; | ||
debug(`${name}:${padStart(id, 5)}`, `[${namespace}] ${arg1}`, ...args); | ||
}; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@linaria/logger", | ||
"description": "Blazing fast zero-runtime CSS in JS library", | ||
"version": "3.0.0-beta.20", | ||
"version": "4.0.0-beta.0", | ||
"bugs": "https://github.com/callstack/linaria/issues", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -1,5 +0,7 @@ | ||
export declare const debug: (namespaces: string, arg1: unknown, ...restArgs: unknown[]) => void; | ||
export declare const info: (namespaces: string, arg1: unknown, ...restArgs: unknown[]) => void; | ||
export declare const warn: (namespaces: string, arg1: unknown, ...restArgs: unknown[]) => void; | ||
export declare const error: (namespaces: string, arg1: unknown, ...restArgs: unknown[]) => void; | ||
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; | ||
export declare const notify: (message: string) => void; | ||
export declare 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
21073
138