Closed klauer closed 5 years ago
To clarify: the approach is to modify the "name" field instead of the "message" because twincat events require pre-defined messages?
Yes @ZLLentz, as far as I know, that is a TwinCAT requirement. I'd be happy to be proven wrong, though.
Seems like a strange choice (in the design of twincat). I suppose they decided that every library should define its own events? Either way this seems good, has the nice effect of syncing the twincat event feed and the syslog, and frees us from the tyranny of the event system tsars.
I believe it's like that for 2 main reasons: decoupling the messages from the code by requiring the definition of the events, and for ease of localization (DE/EN).
And I was proven wrong! Thanks @ghalym 😄
With ipArguments
it's possible to tweak the message itself. Also, this PR doesn't touch on the listener which should've been included - i.e., for getting NC errors and such piped into syslog somehow.
I'll close this for now and open another with a better/more shiny solution.
I was writing a long comment but now it's invalid. Looking forward to the next iteration.
Closes #10
First pass at logging to the event logger + EPICS PV. To get the PV (
:LogMessage
), it will require the user to instantiate and pragmaFB_Logger
.With the following code:
The event logger outputs:
This message also goes via UDP to syslog -> logstash -> elastic search. The logstash JSON is:
This required adding a new
EventType
"LCLSLoggingEventClass
" which maps error codes onto specific, fixed strings which are stored in the type system (such that the locale can be used to determine if it should be displayed in English or German). This data type is pinned such that it's accessible to projects which import the library:I am not using this event logger system as it's intended, as you can see in the following:
Error 163 10/28/2019 11:35:14 AM 920 ms | 'VirtualMotor.Project.Main.fbLogger: the message': Critical
The event type gives the message "Critical
" here, which should be the full user-defined message. The intention is to keep these fixed/unmodifiable at runtime.However, I modify the "name" portion, in single quotes above (
'VirtualMotor.Project.Main.fbLogger: the message'
) at runtime, repurposing it to hold oursPath
andsMessage
.Does this seem a reasonable approach? (@ghalym @n-wbrown @slacAWallace @ZLLentz)