Comparing version 1.0.0 to 1.0.1
@@ -40,3 +40,3 @@ "use strict"; | ||
mySettings.config.printTimestamp && args.unshift(`[${(new Date()).toUTCString()}]`); //add timestamp to logs | ||
mySettings.config.printTimestamp && type !== 'time' && args.unshift(`[${(new Date()).toUTCString()}]`); //add timestamp to logs | ||
if (config && config.trace) { | ||
@@ -43,0 +43,0 @@ console[method].apply(console, args); |
{ | ||
"name": "leo-logger", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "NodeJS Logger by LeoInsights. Logging the way it should be!", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/LeoPlatform/Nodejs/utils/logger" | ||
"url": "https://github.com/LeoPlatform/leo-logger" | ||
}, | ||
@@ -14,0 +14,0 @@ "keywords": [ |
# Leo-Logger | ||
Such an awesome logger that we had to break it out from the LEO SDK and make it its own project! | ||
@@ -24,5 +25,41 @@ ## Available methods | ||
```bash | ||
export LEO_LOGGER='/.*/tide' | ||
export LEO_LOGGER='/.*/d' | ||
``` | ||
## Working with namespaces | ||
You can log logs for specific namespaces by passing a string when requiring the leo-logger. Example: | ||
```javascript | ||
const logger = require('leo-logger')('my-special-namespace'); | ||
``` | ||
When you use a namespace, logging works the same, but the output will be prefixed with the namespace: | ||
```javascript | ||
logger.log('My namespaced log'); | ||
// outputs: my-special-namespace my namespaced log | ||
``` | ||
If you want to display logs for certain namespaces only, you can adjust LEO_LOGGER to match the namespace. | ||
```bash | ||
# Example outputting all logs for my-special-namespace | ||
export LEO_LOGGER='/my\-special\-namespace/a' | ||
``` | ||
You may notice in the previous example how it appears we’re using regex. This allows you to employ more powerful namespace logging. | ||
As an example, let’s say you have a shopping cart, and you want to have logs specific to the checkout process. | ||
Each of the checkout pages would include the leo-logger. I'm going to use an example of 2 checkout pages, which would look like this: | ||
```javascript | ||
const logger = require('leo-logger')('checkout-payment'); | ||
``` | ||
```javascript | ||
const logger = require('leo-logger')('checkout-process-order'); | ||
``` | ||
Then if you want to display logs for the process-order page, you would do this: | ||
```bash | ||
export LEO_LOGGER='/checkout\-process\-order/a' | ||
``` | ||
But if you want to display logs for all checkout pages, you can use the power of regex to select everything starting with “checkout”: | ||
```bash | ||
export LEO_LOGGER='/checkout.*/a' | ||
``` | ||
### Loggers | ||
@@ -44,3 +81,6 @@ ```javascript | ||
## To-Do | ||
More documentation with examples with code and output. | ||
# Support | ||
Want to hire an expert, or need technical support? Reach out to the Leo team: https://leoinsights.com/contact |
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
6979
4
85