Incorrect sorting in cTrader of cBot log messages

Created at 26 Aug 2014, 20:38
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
AlexanderRC's avatar

AlexanderRC

Joined 04.02.2014

Incorrect sorting in cTrader of cBot log messages
26 Aug 2014, 20:38


Consider the following code of cBot

using System;
using cAlgo.API;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SortDemo : Robot
    {
        protected override void OnStart()
        {
            Timer.Start(new TimeSpan(0,0,0,0,50));
            
        }
        
		protected override void OnTimer()
		{
            for (int i = 0; i < 10; i++) {
                Print("This is a log message");
                Print("This is a log message with param: {0}", 42);
            }
		}

        private long printCounter = 0;
        
        new public void Print(object value)
        {
            printCounter++;
            base.Print("{0}: {1}", printCounter, value);
        }

        new public void Print(string message, params object[] parameters)
        {
            printCounter++;
            base.Print(printCounter.ToString() + ": " + message, parameters);
        }
    }
}

Run it for a couple of seconds in cAlgo and in cTrader. In cAlgo, on cBot Log, the messages are sorted correctly. In cTrader they are out of order. See the screenshot.

This makes postmortem debugging very hard when cBot fails in production.


@AlexanderRC
Replies

Spotware
27 Aug 2014, 15:37

Thank you for reporting this issue. This problem occurs if cBot prints several messages in one millisecond. We will fix it.

For now you can add some incremental prefix (like "0000012", "0000013", etc.) to every message and then sort cBot Log by Message column.


@Spotware

AlexanderRC
27 Aug 2014, 15:43

Leading zeros are of some help but diagnostic messages from cTrader internals would go to the back or front of the list if sorted by message contents.


@AlexanderRC