iocLogPrefix incompatible with VxWorks logMsg

Bug #1983385 reported by Dirk Zimoch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
New
Undecided
Unassigned

Bug Description

When defining a iocLogPrefix, messages generated with logMsg on VxWorks contain the prefix before and after each format specifier, including those generated by the system for thread id. No problem with errlogPrintf though.

On the VxWorks shell I do:
iocLogPrefix "[PREFIX]"
errlogPrintf "with errlogPrintf %s number %d\n", "hello",3
logMsg "with logMsg %s number %d\n", "hello",3

On the log server I see:
[PREFIX]with errlogPrintf hello number 3
[PREFIX]0x[PREFIX]574140[PREFIX] ([PREFIX]tShell0[PREFIX]): [PREFIX]with logMsg [PREFIX]hello[PREFIX] number [PREFIX]3[PREFIX]

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

Which Base version/series are you working with?

fyi. iocLogPrefix was added in 3.15.0.1.

You might also like to test my as yet unreleased rewrite of errlog on 7.0 branch.

https://github.com/epics-base/epics-base/pull/113

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote (last edit ):

I am working with 7.0.6, based on commit 59124459 (tag R7.0.6)
I will try your modifications.

The origin of the problem is that the code in modules/libcom/src/osi/os/vxWorks/logMsgToErrlog.cpp implements a low-level i/o write() function that is called multiple times per logMsg (once for each format and once for each literal string in between) but it calls the high-level i/o function errlogPrintfNoConsole which expects whole messages, not fragments.
Thus, not only the whole message gets prefixed but each fragment.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

The errlog modifications do nothing for this bug.

Also, I noticed several uses of %z in your code. VxWorks does not support %z, even in version 6.9.

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

> The origin of the problem is .../vxWorks/logMsgToErrlog.cpp

Agreed.

That said, logClientSend() in logClient.c could be made smarter and only send logClientPrefix before the first character following a newline ('\n'). This would require scanning through each message string, which would have the added (I think) benefit of prefixing every line of a multi-line message.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote (last edit ):

I started working on it. My approach is to accumulate the message (up to \n) in errlog.c.

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.