In questo codice var logger = {
messages: {
'Initialization Complete': "Inizializzazione completata:\nBid Price 0: {bidPrice}\nAsk Price 0: {askPrice}\n",
'Order Action': 'Ordine {action}: {orderCode}\n',
'Order Deleted': 'Ordine cancellato: {orderCode}\n',
'LevelChange': "Livello da {lastLevel} all'attuale livello {priceLevel}\n",
'PriceChange': "Prezzo da {previousPrice} all'attuale prezzo {currentPrice}\nOra: {currentTime}\r\n" + separator,
'message': "{message}\r\n" + separator
},
messageTemplates: {},
init: function() {
for (var type in this.messages) {
this.messageTemplates[type] = this.messages[type];
}
},
formatMessage: function(template, data) {
return template.replace(/{(\w+)}/g, function(match, key) {
return typeof data[key] !== 'undefined' ? data[key] : match;
});
},
formatState: function(bookState) {
var book = bookState ? bookState.book : UserContext.book;
var status = UserContext.status;
return separator +
"Bid Price \tBid Quant.\tAsk Price \tAsk Quant.\r\n" +
separator +
book.BID.Prices[0] + "\t\t" + book.BID.Quantities[0] +
"\t\t" + book.ASK.Prices[0] + "\t\t" + book.ASK.Quantities[0] + "\r\n" +
separator +
"Numero Operazione: " + status.numOperazione + "\r\n" +
separator;
},
log: function(type, data, includeFormattedState) {
includeFormattedState = includeFormattedState !== false;
var template = this.messageTemplates[type];
if (!template) return;
var message = separator + this.formatMessage(template, data || {});
if (includeFormattedState && (type === 'Initialization Complete' || type === 'LevelChange')) {
message += this.formatState();
}
Log(message);
},
logFullBook: function() {
var book = UserContext.book;
var logParts = ["BID:\n"];
var levels = { BID: CONFIG.LEVELS.BID + 1, ASK: CONFIG.LEVELS.ASK + 1 };


function logSide(side, maxLevel) {
        for (var level = 0; level < maxLevel; level++) {
            logParts.push("Level " + level + ": Price = " + book[side].Prices[level] + ", Quantity = " + book[side].Quantities[level] + "\n");
        }
    }
    logSide('BID', levels.BID);
    logParts.push(separator, "ASK:\n");
    logSide('ASK', levels.ASK);
    this.log('message', { message: logParts.join('') }, false);
},
logLevelChange: function(lastLevel, priceLevel) {
    logger.log('LevelChange', { lastLevel: lastLevel, priceLevel: priceLevel }, true);
},
initializeOrderAndLog: function() {
    var originalBook = UserContext.book;
    var sideLevels = UserContext.targetPriceLevels;
    var initialPrice = BookUtils.getData(originalBook, CONFIG.ORDER_SIDE, sideLevels[CONFIG.ORDER_SIDE], 'Price');
    var initialOrder = OrderUtils.processOrModOrder(CONFIG.ORDER_SIDE, stock, initialPrice);

    this.log('Initialization Complete', {
        bidPrice: UserContext.prices.BID.current,
        askPrice: UserContext.prices.ASK.current
    }, true);
    this.log('Order Action', { action: 'inserito', orderCode: initialOrder.OrderCode });
    this.logFullBook();
    return initialOrder;
},
logPriceChange: function(ctx, price) {
    this.log('PriceChange', {
        previousPrice: ctx.lastPrice,
        currentPrice: price,
        currentTime: Now().ToString("HH:mm:ss.ff")
    });
    ctx.lastPrice = price;
}
};

logger.init(); sposta  Numerooperazione da formatState aggiungendo una riga a messages  'Operation Number': "Numero Operazione: aggiungendo i riferimenti corretti sia in messages sia nella chiamata in formatstate