@wokebuild/log v0.1.6
Woke log
A better and more secure console logging experience.
Contents
Install
To use log
,
yarn add @wokebuild/log # npm i @wokebuild/log
Usage
Import the WokeLog library at the top level of your project.
import WokeLog from '@wokebuild/log';
new WokeLog();
console.log('random value'); // Woke Signatures here: random value.
Then you can your console.log
as usual. This should include the WokeLog
prefix and log your value.
The WokeLog Library also accepts an object
export default interface IOptions {
disableOn?: 'development' | 'production'; // You can use this to specify if you want the WokeLog library to be disabled in a certain environment
disableConsoleOn?: 'development' | 'production'; // You can use this to disable console entirely in a specific environment
}
Example:
new WokeLog({ disableConsoleOn: 'development' }); // This will disable the WokeLog library on development environment.
console.log('sensitive secret here'); // This wont be executed.
The disableConsoleOn
option that was passed to the WokeLog
library will make sure that the console.log
statement is not executed.
The disableOn
&& disableConsoleOn
depends on your process.env.NODE_ENV
to work perfectly. That is, it compares the environment passed from the disableOn
|| disableConsoleOn
option with the environment in your process.env.NODE_ENV
to know when to disable the WokeLog library or the console
statements itself..
The Woke log library scans the arguments
passed to the console.log
function to check if any of the ...args
inside your console.log
function is a potential secret. It does this by comparing the arguments
passed to console.log
with the values of your current environment: process.env
. It throws an error if any potential secret is found.
Example:
console.log('secret', process.env.AWS_ACCESS_KEY_ID); // Woke Signatures here: ************ is a valid secret for the key: AWS_ACCESS_KEY_ID
This will throw a warning if an actual AWS_ACCESS_KEY_ID
is found in the process.env
to notify the user that they are logging a potential secret.
Supported console methods
The woke log library currently only supports these console methods:
console.log
,console.clear
,console.warn
,console.profileEnd
,console.debug
,console.info
,console.error
Contributing
Contributions of any kind are welcome! See the contributing guide.
Thanks goes to these contributors!
Roadmap
Features
- Disable logging entirely in a defined environment instead of hiding secrets.
- Support for
console.table
. - AI to scan values passed to
console.log
and report potential sensitive logs.