Show / Hide Table of Contents

Class LogMessage

Represents a log message that can be added to the Logger.

Inheritance
object
LogMessage
ExceptionLogMessage
Namespace: ABB.Robotics.RobotStudio
Assembly: ABB.Robotics.RobotStudio.dll
Syntax
public class LogMessage
Remarks

This class can be used as it is, or it is possible to inherit from it to attach additional data to a log message.

Examples
Project.UndoContext.BeginUndoStep("Logger");
try
{
    // Add two categories.
    if (!Logger.CategoryCaptions.ContainsKey("MyKey"))
    {
        Logger.CategoryCaptions.Add("MyKey", "My Category");
        Logger.CategoryCaptions.Add("AnotherKey", "Another Category");
    }

    // Add two messages with different category.
    Logger.AddMessage(new LogMessage("This is just a test message!", "MyKey"));
    Logger.AddMessage(new LogMessage("This is just a test message!", "AnotherKey"));

    // How to create log messages with hyperlinks.
    string path = @"C:\";
    string textString = "Start text {{browse to file here}} more text {{google link here}} more text {{message box here}} end text";

    // Add a message with three hyperlinks.
    Logger.AddMessage(new LogMessage(textString, (index) =>
    {
        // If the user clicks a hyperlink this action will be called with the hyperlink index as argument. Index is zero based and is counted left to right.
        switch (index)
        {
            // If the left-most hyperlink is clicked, index will be 0. 
            case 0:
                Process.Start("explorer.exe", $"/select,\"{path}\"");
                break;
            // If second (from the left) hyperlink is clicked, index will be 1. 
            case 1:
                Process.Start("http://google.com");
                break;
            // If third hyperlink is clicked, index will be 2. 
            case 2:
                MessageBox.Show("Message box");
                break;
            default:
                break;
        }
    }));
}
catch
{
    Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
    throw;
}
finally
{
    Project.UndoContext.EndUndoStep();
}

Constructors

View Source

LogMessage(string)

Initializes a new instance of the LogMessage class with the specified message text.

Declaration
public LogMessage(string text)
Parameters
Type Name Description
string text

The message text.

View Source

LogMessage(string, LogMessageSeverity)

Initializes a new instance of the LogMessage class with the specified message text and severity.

Declaration
public LogMessage(string text, LogMessageSeverity severity)
Parameters
Type Name Description
string text

The message text.

LogMessageSeverity severity

The severity of the message.

View Source

LogMessage(string, Action<int>)

Initializes a new instance of the LogMessage class with the specified message text and hyperlink(s).

Declaration
public LogMessage(string text, Action<int> requestNavigate)
Parameters
Type Name Description
string text

The message text including hyperlink(s) enclosed in double curly bracers. Example: Click {{here}} or {{here}}.

Action<int> requestNavigate

Called when a hyperlink is clicked in the UI. Input is the index of the hyperlink in the message.

View Source

LogMessage(string, string)

Initializes a new instance of the LogMessage class with the specified message text and category.

Declaration
public LogMessage(string text, string category)
Parameters
Type Name Description
string text

The message text.

string category

The message category.

View Source

LogMessage(string, string, LogMessageSeverity)

Initializes a new instance of the LogMessage class with the specified message text, category and severity.

Declaration
public LogMessage(string text, string category, LogMessageSeverity severity)
Parameters
Type Name Description
string text

The message text.

string category

The message category.

LogMessageSeverity severity

The severity of the message.

View Source

LogMessage(string, string, LogMessageSeverity, string)

Initializes a new instance of the LogMessage class with the specified message text, detailed text, category, severity and help topic.

Declaration
public LogMessage(string text, string category, LogMessageSeverity severity, string helpTopic)
Parameters
Type Name Description
string text

The message text.

string category

The message category.

LogMessageSeverity severity

The severity of the message.

string helpTopic

The helpt topic.

View Source

LogMessage(string, string, string, LogMessageSeverity)

Initializes a new instance of the LogMessage class with the specified message text, category and severity.

Declaration
public LogMessage(string text, string category, string detailedText, LogMessageSeverity severity)
Parameters
Type Name Description
string text

The message text.

string category

The message category.

string detailedText

A more detaild version of the message text.

LogMessageSeverity severity

The severity of the message.

View Source

LogMessage(string, string, string, LogMessageSeverity, string)

This constructor is for internal use only.

Declaration
public LogMessage(string text, string detailedText, string category, LogMessageSeverity severity, string helpTopic)
Parameters
Type Name Description
string text
string detailedText
string category
LogMessageSeverity severity
string helpTopic

Properties

View Source

CanActivate

Indicates if this message can be double-clicked to display more information.

Declaration
public virtual bool CanActivate { get; }
Property Value
Type Description
bool
View Source

Category

Gets the message category. This property is used to categorize log messages which is related to each other. A PowerPack for example, could define its own category for all messages that it logs.

Declaration
public string Category { get; }
Property Value
Type Description
string

The message category.

View Source

DetailedText

A more detailed description that if set to anything will be shown in a dialog when the message is activated.

Declaration
public string DetailedText { get; }
Property Value
Type Description
string
View Source

HelpTopic

This property is for internal use only.

Declaration
public string HelpTopic { get; }
Property Value
Type Description
string
View Source

RequestNavigate

Called when a hyperlink is clicked in the UI. Input is the index of the hyperlink in the message.

Declaration
public Action<int> RequestNavigate { get; set; }
Property Value
Type Description
Action<int>
View Source

SequenceNumber

Gets the sequence number of the message severity of the message.

Declaration
public int SequenceNumber { get; }
Property Value
Type Description
int

The sequence number is an integer that is increased each time a new message is created.

View Source

Severity

Gets the severity of the message. The severity is specified by the LogMessageSeverity enumerator.

Declaration
public LogMessageSeverity Severity { get; }
Property Value
Type Description
LogMessageSeverity

The severity of the message.

View Source

Text

Gets the message text.

Declaration
public string Text { get; }
Property Value
Type Description
string

The message text.

View Source

TimeStamp

Gets the date and time when the message was logged.

Declaration
public DateTime TimeStamp { get; }
Property Value
Type Description
DateTime

The date and time when the message was logged.

Methods

View Source

Equals(object)

Indicates whether the current object is equal to another object

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj
Returns
Type Description
bool
Overrides
object.Equals(object)
View Source

GetHashCode()

Returns the hash code for this object.

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
object.GetHashCode()

Events

View Source

MessageActivated

Raised when this message is activated, e.g. double-clicked in the GUI.

Declaration
public event LogMessageActivatedEventHandler MessageActivated
Event Type
Type Description
LogMessageActivatedEventHandler
  • View Source
In this article
Back to top Copyright © 2025 ABB