Main Content

SystemLog

Get current console log from target computer

Since R2020b

Description

A SystemLog object represents the console log from the target computer at the time that the object is created by the slrealtime.SystemLog function.

Creation

slog_object = slrealtime.SystemLog(target_object) creates a system log object that contains a table of current target computer console messages in its messages property.

To view the target computer console log, create a SystemLog object and view its messages property or use the Simulink® Real-Time™ system log viewer slrtLogViewer.

Properties

expand all

The messages property value is a table of the current console log messages.

Object Functions

slrtLogViewerOpen the Simulink Real-Time System Log Viewer tab in the Simulink Real-Time Explorer to view the console log from the target computer

Examples

collapse all

To work with multiple target computers, make the computer names available by using a targets object.

Create targets object my_tgs. Add target computers to the targets object. Assign target computers to target objects. Create target settings object and list the target computer names.

tg = slrealtime('TargetPC1');
slog = slrealtime.SystemLog(tg);
slog.messages
ans =

  13×4 table

         Timestamp                             Message                        Severity    Category
    ____________________    ______________________________________________    ________    ________

    26-Nov-2019 21:27:33    "Target IP address: 192.168.7.5"                   "info"        2    
    26-Nov-2019 21:28:44    "Loading model slrt_ex_mds_and_tasks"              "info"        0    
    26-Nov-2019 21:28:44    "Loading model slrt_ex_mds_and_tasks"              "info"        0    
    26-Nov-2019 21:28:44    "Waiting for start command"                        "info"        0    
    26-Nov-2019 21:28:44    "Waiting for start command"                        "info"        0    
    26-Nov-2019 21:28:44    "loglevel = info"                                  "info"        0    
    26-Nov-2019 21:28:44    "loglevel = info"                                  "info"        0    
    26-Nov-2019 21:28:44    "pollingThreshold = 0.0001"                        "info"        0    
    26-Nov-2019 21:28:44    "pollingThreshold = 0.0001"                        "info"        0    
    26-Nov-2019 21:28:44    "relativeTimer = [unset]"                          "info"        0    
    26-Nov-2019 21:28:44    "relativeTimer = [unset]"                          "info"        0    
    26-Nov-2019 21:28:44    "stoptime = 2"                                     "info"        0    
    26-Nov-2019 21:28:44    "stoptime = 2"    
  1. To use the custom message functions in an S-function, include the header file. Place an ifdef statement around the include.

    #ifdef SIMULINK_REAL_TIME
    #include "slrt_log.hpp"
    #endif
  2. In an S-function, place an ifndef around the function call.

    #ifdef SIMULINK_REAL_TIME
    slrealtime::log_error("Some custom message.");
    #endif
  3. Call the function for the selected severity level.

    slrealtime::log_trace("Some custom message.");

    or

    slrealtime::log_debug("Some custom message.");

    or

    slrealtime::log_info("Some custom message.");

    or

    slrealtime::log_warning("Some custom message.");

    or

    slrealtime::log_error("Some custom message.");

    or

    slrealtime::log_fatal("Some custom message.");

Version History

Introduced in R2020b