Home » Eclipse Projects » Papyrus for Real Time » log levels?
log levels? [message #1780988] |
Tue, 30 January 2018 21:47  |
Eclipse User |
|
|
|
Hi,
it would be useful to have support for different 'log levels', so that the user could adjust, at code invocation time, which log statements should produce console output. Might there already be support for something like this?
Thanks!
Juergen
|
|
|
Re: log levels? [message #1781010 is a reply to message #1780988] |
Wed, 31 January 2018 09:18   |
Eclipse User |
|
|
|
Hi Juergen,
Thank you for the suggestion.
What kind of log are you referring to? Toolset? Runtime? Application (i.e., as part of the log port capabilities?
What do you mean by "at code invocation time"? At the time the executable is launched (e.g., through command line parameters) or during the execution (e.g., through external communications)?
From a purely application point of view, I agree that it could be useful. I have seen and used custom tailored logging mechanisms in UML-RT-based tooling that would be used to automatically enhance the provided logging capability, including adding severity, system information, and enhanced encoding. Most of these were custom development using UML-RT's capabilities and not at the level of modifying the runtime. As those were proprietary implementations seen during consulting engagements, I do not have access to the models or code implementing them.
Note that, since a UML-RT based solution has access to the command line parameters of the executable, those could be used to control the output of the logging mechanism.
Would that satisfy your needs?
|
|
|
Re: log levels? [message #1781013 is a reply to message #1781010] |
Wed, 31 January 2018 10:01   |
Eclipse User |
|
|
|
I assume you are talking about the Log protocol, and logging in action code with log levels like "debug", "info", "warning", "error", "critical", "fatal", etc. Correct?
If so, unfortunately the RTS library doesn't support that. You can take a look at "umlrtlogprotocol.hh" in the RTS. There is only a "log" method that accepts different types of parameter, and a "show" method which is log, with no newline appended. There are other useful methods, like "redirect", to send the log to a file, rather than stdout, but unfortunately no support for logging levels.
Nevertheless it shouldn't be too difficult to add support for this. If this is what you are looking for, could you open an enhancement request in bugzilla?
|
|
|
Re: log levels? [message #1781053 is a reply to message #1781013] |
Wed, 31 January 2018 15:53   |
Eclipse User |
|
|
|
Yes, Ernesto, that is what I had in mind.
In the absence of built-in RTS support for this, it seems to me that it should also be possible to create support for this on the application level (i.e., in the model) via, e.g., a user defined operation 'myLog(s : string, logLevel : int, currentLogLevel : int)' that uses the built-in 'log' method, but only when the 'logLevel' parameter exceeds the 'currentLogLevel' parameter (which indicates the log level that the user wants the code to run at and is provided at code invocation time).
Unfortunately, it seems that this operation would have to replicated in every capsule that wants to use it, right? Also, the 'currentLogLevel' command line argument would have to be communicated to every capsule...
Am I missing something?
Juergen
|
|
| |
Re: log levels? [message #1781055 is a reply to message #1781053] |
Wed, 31 January 2018 16:17   |
Eclipse User |
|
|
|
Well, there are some ways to achieve something close to a global definition (although as you know, UML-RT was design with strong encapsulation in mind, and therefore disallowing global definitions).
One, which I use often is to add a UML Artifact element, apply the ArtifactProperties stereotype and in the stereotype enter the contents, which can be any C++ definition. Then, in any capsule or class that needs these add a Dependency to the Artifact, or equivalently, add the CapsuleProperties stereotype and in the headerPreface add an #include statement to the artifact.
An alternative approach, and perhaps more in line with the UML-RT style of modelling, is to use SAPs and SPPs and define this new custom logging service. Define a capsule called, say "MyLogger" with an SPP called say "newLog" typed by a "NewLog" protocol that has a "log" message with the parameters you want, including say a string and an int level. Then, in your client capsules, instead of adding a standard Log port, you ass a NewLog SAP called "newLog" (to match the one in MyLogger). Let the default registration be automatic, and in action code you should be able to write something like this:
newLog.log("message", level).send();
So there is a bit of extra syntax in the action, but it should work. Then you don't have to manually add dependencies from each client, although you do have to add an SAP, but that is no different than adding a standard log port. Also, only NewLogger needs to be able to get command-line arguments.
Hope this helps.
|
|
| |
Re: log levels? [message #1781140 is a reply to message #1781056] |
Thu, 01 February 2018 16:03  |
Eclipse User |
|
|
|
Ernesto and Charles,
makes sense. I like the SAP/SPP solution (and the auto-completion in the new action language would ease the burden of the extra syntax).
Thanks!
Juergen
|
|
|
Goto Forum:
Current Time: Fri May 16 23:57:24 EDT 2025
Powered by FUDForum. Page generated in 0.04692 seconds
|