Home

aliazzz

Project Members:

Download DebugLogger

CODESYS V23 version by Sebastian Rau: https://github.com/SebastianRau/Codesys2-DebugMessages

DebugLogger

Goal:
A quick and easy "replacement" of the Device Log, implemented as a pure software solution.

Use case:
Add debug messages (or other info) in a pure software global message Queue.
Advantage of this approach over the Device Log is that this solution is easier to implement and one has greater control over the global message Queue.
The global message Queue can be accessed via HMI while the device log cannot (at least not this easy)

Usage:
Include the .Library in your project,
(optional) write time of the Event to stDebugInformation.dtActualTime := SOME_DT_VAR;
Call function DebugLog(...) to add a Message to the Ringbuffer.

Parameters are:

    sMessage : T_MaxString;             // Message (max 255 chars)
    ePriority : E_DebugMessagePriority; // A given priority

Priorities are:

    DEBUG := 0
    INFO := 1
    WARN := 2
    ERROR := 3
    FATAL := 4

All messages will be added to the stDebugInformation Struct in Global Variables of the Library.

Changing the default ringbuffer size;

No coding neccesary!
You can change the iMaxDebugEntries in the DebugLogParam library parameter dialog

Opening the global message Queue online;

Open the library manager, select GVL_DEBUG in DebugLogger and doubleclick it.


Discussion

  • i-campbell

    i-campbell - 2020-04-02

    Merge Request:
    Please review/accept this change. I have added support for using this from a library, as libraries do not have access to parameters. I have also added a "unit test". In this change, I also made the old call (DebugLog()) just a wrapper for the new call (DebugLog_Lib()) to make future changes easier.

     
    👍
    1
    • aliazzz

      aliazzz - 2020-04-02

      Great work! Will check and merge.

      Are you saying that DebugLog() is backward compatible available but deprecated, so new development should use the DebugLog_Lib() function?

       

      Last edit: aliazzz 2020-04-02
      • i-campbell

        i-campbell - 2020-04-02

        Hmm, tough call on the deprecation.
        Pros for deprecation:
        I think DebugLog_Lib() works in all cases.
        Can easily store the Log in retain.
        Can easily have multiple logs.

        Cons for deprecation:
        but DebugLog() is easier to use if you just want to write a log (and you have control over the application Library Manager).

        I would be happy to deprecate it though, in favour of the more universal DebugLog_Lib(). In which case.. we should rename the new function to DebugLog2(). Or, if you are happy to make a breaking change, simply replace it.

        I have no attachment to the old implementation, so others may feel unkindly if we broke it for them.

         

Log in to post a comment.