flex-plugins-utils-logger
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -10,9 +10,5 @@ import chalk from 'chalk'; | ||
declare class Logger { | ||
private static boldRegexMatcher; | ||
private static boldRegexReplacer; | ||
private static italicRegexMatcher; | ||
private static italicRegexReplacer; | ||
private static codeRegexMatcher; | ||
private static codeRegexReplacer; | ||
private static formatter; | ||
private readonly options; | ||
private bold; | ||
constructor(options?: LoggerOptions); | ||
@@ -19,0 +15,0 @@ debug: (...args: any[]) => void; |
@@ -35,2 +35,3 @@ "use strict"; | ||
var _this = this; | ||
this.bold = chalk_1.default.bold; | ||
this.debug = function () { | ||
@@ -112,14 +113,11 @@ var args = []; | ||
} | ||
var bold = msg.match(Logger.boldRegexMatcher); | ||
if (bold) { | ||
return _this.markdown(msg.replace(Logger.boldRegexReplacer, chalk_1.default.bold(bold[0]))); | ||
for (var key in Logger.formatter) { | ||
if (Logger.formatter.hasOwnProperty(key)) { | ||
var formatter = Logger.formatter[key]; | ||
var match = msg.match(formatter.matcher); | ||
if (match) { | ||
return _this.markdown(msg.replace(formatter.replacer, formatter.render(match[0]))); | ||
} | ||
} | ||
} | ||
var italic = msg.match(Logger.italicRegexMatcher); | ||
if (italic) { | ||
return _this.markdown(msg.replace(Logger.italicRegexReplacer, chalk_1.default.italic(italic[0]))); | ||
} | ||
var code = msg.match(Logger.codeRegexMatcher); | ||
if (code) { | ||
return _this.markdown(msg.replace(Logger.codeRegexReplacer, chalk_1.default.magenta(code[0]))); | ||
} | ||
return msg; | ||
@@ -155,8 +153,39 @@ }; | ||
} | ||
Logger.boldRegexMatcher = /(?<=\*{2})(.*?)(?=\*{2})/; | ||
Logger.boldRegexReplacer = /\*{2}(.*?)\*{2}/; | ||
Logger.italicRegexMatcher = /(?<=\*)(.*?)(?=\*)/; | ||
Logger.italicRegexReplacer = /\*(.*?)\*/; | ||
Logger.codeRegexMatcher = /(?<=\{{2})(.*?)(?=\}{2})/; | ||
Logger.codeRegexReplacer = /\{{2}(.*?)\}{2}/; | ||
Logger.formatter = { | ||
bold: { | ||
matcher: /(?<=\*{2})(.*?)(?=\*{2})/, | ||
replacer: /\*{2}(.*?)\*{2}/, | ||
render: chalk_1.default.bold, | ||
}, | ||
italic: { | ||
matcher: /(?<=\*)(.*?)(?=\*)/, | ||
replacer: /\*(.*?)\*/, | ||
render: chalk_1.default.italic, | ||
}, | ||
code: { | ||
matcher: /(?<=\{{2})(.*?)(?=\}{2})/, | ||
replacer: /\{{2}(.*?)\}{2}/, | ||
render: chalk_1.default.magenta, | ||
}, | ||
link: { | ||
matcher: /(?<=\[{2})(.*?)(?=\]{2})/, | ||
replacer: /\[{2}(.*?)\]{2}/, | ||
render: chalk_1.default.blue, | ||
}, | ||
success: { | ||
matcher: /(?<=\+{2})(.*?)(?=\+{2})/, | ||
replacer: /\+{2}(.*?)\+{2}/, | ||
render: chalk_1.default.green, | ||
}, | ||
warning: { | ||
matcher: /(?<=\!{2})(.*?)(?=\!{2})/, | ||
replacer: /\!{2}(.*?)\!{2}/, | ||
render: chalk_1.default.yellow, | ||
}, | ||
error: { | ||
matcher: /(?<=\-{2})(.*?)(?=\-{2})/, | ||
replacer: /\-{2}(.*?)\-{2}/, | ||
render: chalk_1.default.red, | ||
}, | ||
}; | ||
return Logger; | ||
@@ -163,0 +192,0 @@ }()); |
{ | ||
"name": "flex-plugins-utils-logger", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Flex Plugins Logger", | ||
@@ -55,3 +55,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "0151ee981516c9bcf1c4ee948288efb726f1fdbb" | ||
"gitHead": "e0e99f7c41931ab5a27cbf7608f3b9b76bc6c1b4" | ||
} |
@@ -8,1 +8,49 @@ ![npm](https://img.shields.io/npm/v/flex-plugins-utils-logger.svg?style=flat-square) | ||
General logger methods used by various Flex Plugins repos | ||
## Modules | ||
This library provides the following modules | ||
### logger | ||
The `logger` provides the following methods: | ||
* `debug` Only logs if `DEBUG=true` or `TRACE=true` is set | ||
* `info` Logs the text as info level | ||
* `warning` Logs the text as warning level in yellow | ||
* `error` Logs the text as error level in red | ||
* `trace` Only logs if `TRACE=true` is set; this is the most verbose mode | ||
* `success` Logs the text in info level in green | ||
* `newline` Adds a new line | ||
* `notice` Logs the text as info level in cyan | ||
* `clearTerminal` Clears the terminal window if `PERSIST_TERMINAL=true` is not set | ||
All of these log commands support some basic formatting: | ||
**bold** | ||
Texts can be bolded using `**the text to bold**`. | ||
**italic** | ||
Texts can be italicized using `*the text to italicize*`. | ||
**success** | ||
Texts can be shown in green using `++the text in green++`. | ||
**warning** | ||
Texts can be shown in yellow using `!!the text in yellow!!`. | ||
**error** | ||
Texts can be shown in red using `--the text in red--`. | ||
**link** | ||
Texts can be shown in blue using `[[the text in blue]]`. | ||
**code** | ||
Texts can be shown in magenta using `{{the text in blue}}`. |
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
39561
601
56