Exceptionally minimal browser console log tool.
- tiny footprint
- preserve line numbers in console
- enable/disable loggers and keep them in the code
- No dependencies
To run the example, run a static server in this root folder, and load the eample page in a browser.
Simply import the module and run with it.
import { logTool } from '@rmc2/log-tool';
// Create a logger:
const loggerA = logTool(true, {
namespace: 'Logging Module A:'
})
loggerA('log any value as necessary'); // Logging Module A: log any value as necessary
// Disabled:
const loggerB = logTool(false, {
namespace: 'Logging Module B:'
})
loggerB('This has no output'); // Disabled, no output.
// return to first logger
loggerA('Logging more things.'); // Logging Module A: Logging more things.
// Simple defaults
const loggerC = logTool();
loggerC('Logging!') // Logging!
- Change so you do no have to pass a method in to use a different method
- Use session storage for global overrides
- Actual unit tests
- Less verbose API
- Push to npm (...)
There are much fancier tools. Really.
See LICENSE file.