Moddable-OpenSource / moddable

Tools for developers to create truly open IoT products using standard JavaScript on low cost microcontrollers.
http://www.moddable.com
1.32k stars 236 forks source link

Allow custom implementations of LogMachine with xsbug_log #1364

Closed cmidgley closed 2 months ago

cmidgley commented 2 months ago

This PR is a proposal to add a tiny bit of extensibility to xsbug_log by allowing the LogMachine class to be overridden by an external module. Changes include:

I am requesting this change for a couple of reasons:

1) Support for colorization using the \, \, ... tags

I'm glad to provide this if interested, either as an update to the default LogMachine or as an optional one such as xsbug-colorlogmachine.js that can be selected with XSBUG_LOGMACHINE 2) I have a custom test runner, similar in concept to what xsbug does but unique to fit my needs, and I'm using xsbug-log to manage the logging and tracking of test executions.

phoddie commented 2 months ago

It is great that you are using the xsbug API for your test runner. I always thought that API would be useful for automation.

It feels a little strange to me to build an extension mechanism into xsbug-log. The implementation is so simple that you could just replace xsbug-log.js and use the same supporting modules. But, I understand that the extension mechanism helps to avoid some code duplication and simplifies integration with mcconfig and mcrun.

We'll get this merged.

Support for colorization using the , , ... tags I'm glad to provide this if interested, either as an update to the default LogMachine or as an optional one such as xsbug-colorlogmachine.js that can be selected with XSBUG_LOGMACHINE

This would be welcome. In the interest of simplicity, It seems fine to just update the default rather than providing an alternate.

mkellner commented 2 months ago

This has been merged and will be available in the next drop.