Oxy-utility is your go-to solution for logging and tracking functionalities in JavaScript applications. Monitor function execution times, and take control of your code's performance effortlessly. Best used with Zustand Controller Architecture.
- Beautiful Console Logs: Enhances debugging experience with visually appealing and informative console logs.
- Execution Stats: Provides detailed statistics on function execution times, aiding in performance analysis.
- Execution Grouping/Chaining: Automatically groups chained function executions for better visibility and understanding of execution chains.
- Exportable Stats: Easily export statistics data to JSON or CSV formats for further analysis or reporting.
- Benchmarking: Compare old and new stats with benchmarking functionality, facilitating performance regression testing.
- Easy Setup: Quick and hassle-free setup process ensures seamless integration into your projects.
- Lightweight: Pure JavaScript implementation with no external dependencies, keeping your project lean and efficient.
- Production Ready: With OxyLocker, Oxy can be used in production for rapid debugging.
- Record (Experimental): Experimental feature to record function arguments and responses, useful for testing automation and debugging.
- Install oxy-utility using npm or yarn:
npm install oxy-utility
- Use it on your Controller / Object of functions
import { Oxy, OxyLocker } from "oxy-utility";
const oxy = Oxy({ // set up the config -
enable: true, // isTestEnv()
log: true,
stats: true,
group: true,
record: true,
fnPrefix: "Controller"
});
// Oxify your controller and thats it.
export const Controller: IController = oxy.oxyfy({
...bearController,
...pandaController,
})
// Optional - lock Oxy, useful for use in production.
// Use your custom unlocking mechanism
const OxyUnlockFn = (userInput) => {
if (yourLogicToUnlock()) { // can be sync - api calls, your wish.
console.log("Authenticated - any message you to share")
return true
}
return false
}
const lockedOxy = OxyLocker(oxy, OxyUnlockFn, "Oxy");
declare global {
interface Window {
Oxy: any
}
}
// export to window for using it.
window.Oxy = lockedOxy
enable
: Indicating whether Oxy should be enabled (true
by default). Setting it tofalse
will turn off Oxy completely.log
: Indicating whetherconsole.log
statements should be enabled (true
by default). If set tofalse
,console.log
statements will be disabled.group
: Indicating whether Oxy should attempt to group chained controllers if they are triggered simultaneously (true
by default).stats
: Indicating whether statistics tracking should be enabled (true
by default).record
: Indicating whether Oxy should record every function's arguments and responses (false
by default). // (experimental)fnPrefix
: A string representing the prefix added toconsole.log
statements ("Controller"
by default).
unlock(userInput)
: If you are using OxyLocker, you will need to 1st unlock it to access the below methods.viewConfig()
: Retrieve the current configuration settings.saveConfig()
: Save the current configuration settings.resetConfig()
: Reset the configuration settings.enable()
: Enable a specific feature. Default will enable Oxydisable()
: Disable a specific feature. Default will disable OxygetStats()
: Retrieve statistics about function execution times.resetStats()
: Reset the statistics.exportStats(fileFormat, formatTime)
: Export statistics data in a specified file format (default: CSV).benchmarkStats()
: Benchmark the statistics.getDeviceInfo()
: Retrieve device information.getRecords()
: Retrieve recorded data.exportRecords(maxSize)
: Export recorded data (default maximum size: 10000).getErrors()
: Retrieve error stack.getProxy()
: Retrieve the proxy object.oxyfy()
: Apply interception to an object.
Note: saveConfig() will store Oxy's configuration in the browser's localStorage, ensuring that once configured, your settings persist even after a page refresh. This seamless storage mechanism enhances usability, particularly in production environments.
In the pipeline for Oxy:
- Oxy Extension: Stay tuned for the upcoming extension release, promising enhanced functionality and efficiency.
- Zustand Middleware: Log updates in your zustand store, this will be plugged into the upcoming extension
- Zustand Controller Boilerplate: Simplifying state management with a dedicated boilerplate for the Zustand Controller Architecture.
- Theme Config: Enable customization of theme for the console.logs
- Enhanced Stats: Expect more comprehensive statistical tracking features.
- TypeScript Integration: Transitioning to TypeScript for improved type safety and developer experience.
- Expanded Functionality: Exporting additional utility functions for broader application support.
Keep an eye out for updates as Oxy evolves to empower your JavaScript projects even further.
Found an issue or have a cool idea? We'd love to hear from you! Feel free to raise any issues or submit feature requests on our GitHub repository. Your feedback helps us improve Oxy and make it even better for everyone. Together, let's make Oxy the best it can be!
Oxy is an open-source project and welcomes contributions from the community. Whether it's bug fixes, new features, or enhancements, your contributions are valuable. To contribute, simply clone the repository, create a feature branch for your changes, and submit a pull request. Let's collaborate and make Oxy the go-to solution for JavaScript logging and tracking functionalities. Join us in shaping the future of Oxy!
If you find Oxy useful, consider giving it a GitHub star to show your support. Your appreciation motivates us to continue improving and expanding its capabilities. Thank you for being part of the Oxy community!