Main Content

SystemLog

Create a system log object that contains the current console log

Since R2020b

Description

A SystemLog object represents the content of the console log from a selected 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.

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

Properties

expand all

Use the severityFilter property to filter the console log messages that are returned by the messages function according to the log level severity. To set the severityFilter to info for a SystemObject slog, use the command:

slog.severityFilter="info"

Use the messageFilter property to filter the console log messages that are returned by the messages function according to the content that appears in log messages. To set the messageFilter for messages that contain the word Ready in SystemObject slog, use the command:

slog.messageFilter="Ready"

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
messagesDisplay console log messages in a system log object
resetUpdate a system log object with current console log messages
tailDisplay a selected number of lines of console log messages in a system log object

Examples

collapse all

The SystemLog object and related functions let you display the console log from a target computer and use filters to search through the log.

Create Target object tg. Create SystemLog object slog that contains the current console log for the target computer.

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

Display the console log content from slog

messages(slog)
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