hi @nikku,
yeah, that`s exactly what a needed and now it’s working fine.
I would like to take the opportunity to ask for a better approach than the current one that i took for intercept the token-simulation log messages to print them in PDF.
For now, i took the log.js (at “bpmn-js-token-simulation/lib/features/log/log.js”) file and at the function
Log.prototype.log = function(options)
i added a eventBus.fire call at the very botton of the function, this way:
Log.prototype.log = function(options) {
const {
text,
type = 'info',
icon = ICON_INFO,
scope
} = options;
domClasses(this._placeholder).add('hidden');
const date = new Date();
const dateString = date.toLocaleTimeString() + ':' + date.getUTCMilliseconds();
this._notifications.showNotification(options);
const iconMarkup = icon.startsWith('<') ? icon : `<i class="${icon}"></i>`;
const colors = scope && scope.colors;
const colorMarkup = colors ? `style="background: ${colors.primary}; color: ${colors.auxiliary}"` : '';
const logEntry = domify(`
<p class="bts-entry ${ type } ${
scope && this._scopeFilter.isShown(scope) ? '' : 'inactive'
}" ${
scope ? `data-scope-id="${scope.id}"` : ''
}>
<span class="bts-date">${ dateString }</span>
<span class="bts-icon">${iconMarkup}</span>
<span class="bts-text">${text}</span>
${
scope
? `<span class="bts-scope" data-scope-id="${scope.id}" ${colorMarkup}>${scope.id}</span>`
: ''
}
</p>
`);
domDelegate.bind(logEntry, '.bts-scope[data-scope-id]', 'click', event => {
this._scopeFilter.toggle(scope);
});
this._content.appendChild(logEntry);
this._content.scrollTop = this._content.scrollHeight;
this._eventBus.fire("MyCustomEvent", {
options,
dateString,
});
};
I understand that this is not a good approach cause, when i update the library, this call is going to disapear.
The other approach that i could use to intercept the log messages is subscribe my custom callbacks to each event triggered by the token simulation (SCOPE_CREATE_EVENT, TRACE_EVENT …), but i would have to implement the same logic already implemented inside the log.js, like the “TRACE_EVENT” that have a lot of if and elses to know what element the simualtion is currently processing.
I would like to know if it’s safe to override the “Log.prototype.log” on my frontend application (angularJS) and re-implement the function, but with my customEvent being triggered, or if there’s any other better approach.
Thank you o/