How to retrieve WB extensions Log Output as a String in ACT console?

Options
Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 409
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
edited December 2022 in General Language Questions

How to retrieve WB extensions Log Output as a String in ACT console?

enter image description here

Tagged:

Best Answer

Answers

  • James Derrick
    James Derrick Administrator, Employee Posts: 248
    First Anniversary Solution Developer Community of Practice Member Ansys Employee 5 Up Votes
    admin
    Options

    Hi Ayush, can you add a bit more context to your question? It's not clear what sort of log output you're looking for here.

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 409
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Options

    Hi James (@James Derrick) , Thanks for the feedback, added some context, I hope this clarifies the question!

  • James Derrick
    James Derrick Administrator, Employee Posts: 248
    First Anniversary Solution Developer Community of Practice Member Ansys Employee 5 Up Votes
    admin
    Options

    That's great Ayush, thanks!

  • Josef Behal
    Josef Behal Member Posts: 22
    First Comment Name Dropper
    Options

    Hi all,

    Is it possible to retrieve the count of error/warning messages in the log?

    Let's say I use ExtAPI.Log.WriteError(...) several times in the code and I would like to know, how many times these error messages were written to the log.

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 409
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    edited March 2023
    Options

    @Josef Behal Log.Stream.ToString() is a string, you can save that in a variable and search for number of occurrences of a particular string. For example:


  • Josef Behal
    Josef Behal Member Posts: 22
    First Comment Name Dropper
    Options

    Yes, this is obvious. In this case, I need to write every time something like ExtAPI.Log.WriteError(Error, error message....) or somehow wrap this function.

    Do I understand correctly that WriteError function just formats the text and does not add any object properties, for example as mechanical error message does?

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 409
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Options

    @Josef Behal, that is correct. WriteError expects only a string argument. That argument is rendered as an Error message in ACT Log in red.

  • Josef Behal
    Josef Behal Member Posts: 22
    First Comment Name Dropper
    Options

    OK, thank you.