Simple winston based logger that produces coloured logs on the console and provides masking of PII Fields.
npm install umang_logger_module
* Standard logging based on environment, example: Production, Staging etc. using ‘winston’ module
* Various log levels supported – info, warn, verbose, error, debug
* Configuration for logging based on severity of log.
* For prod and different environment
* Different colours for levels of log using ‘chalk’ module.
* Configuration for saving the logs in file.
* Configurable log file path from home directory.
* Identifying PII in simple string using regexes, example: card, phone, email.
* Configurable file for identifying PII using fieldname in JSON
* Masking identified PII using node module ‘maskdata’
Configurable file for how we want to mask the PII example by using or x or $ etc.
* Configurable file for how many characters needs to be masked at the start or end of the PII
* Emails are picked from the given string using the regex provided in the table below
* Match function is used to return the array of emails fetched in this case which is masked further.
* Regex used for card number picks up card in the following formats:
* 4111111111111111
* 4111-1111-1111-1111
* 4111 1111 1111 1111
* 378282246310005
* 3782-822463-10005
* 3782 822463 10005
* These picked up numbers are validated by a node module ‘node-luhn’.
* If the card number picked is a valid card number, then the masking is done otherwise no masking is done.
Link: https://www.npmjs.com/package/umang_logger_module
Command: npm i umang_logger_module
* Creating pii-fields.json file
* More fileds can be added or removed as per the masking requirement.
``javascript`
{
"gender": "",
"age": "",
"name": "",
"email": "",
"phone": "",
"cc":"",
"_id":"",
"access_token":""
}
`javascript
{
"email": {
"maskWith" : "x",
"unmaskedStartCharacters" : "1",
"unmaskedEndCharacters" : "2",
"maskAtTheRate ": "false",
"maxMaskedCharactersBeforeAtTheRate" : "10",
"maxMaskedCharactersAfterAtTheRate" : "10"
},
"phone": {
"maskWith" : "x",
"unmaskedStartDigits" : "5",
"unmaskedEndDigits" : "1"
},
"card": {
"maskWith" : "x",
"unmaskedStartDigits" : "4",
"unmaskedEndDigits" : "1"
},
"json": {
"maskWith" : "x"
}
}
``
* #identifier for choosing masking or no masking (default is set as true)
* MASKING_FOR_PII_FLAG="true"
PII File Name
* PII_FILENAME = "pii-fields.json"
Log File Name (mandatory field)
* LOG_FILENAME = "master_"
Log File Path (mandatory field)
* LOG_FILEPATH = ''
identifier for saving in FILE (default is set as false)
* SAVE_IN_FILE = 'true'
Identifier for Log Level for current environment (default set to info)
* LOG_LEVEL = "debug"
Identifier for Log Level for production environment (default set to error)
* PRODUCTION_LOG_LEVEL = ‘error’