Add command to show errlog buffer contents
This commit is contained in:
1 parent
a03d1fbe45
commit
bb5f12b2fa
4 files changed
+71
-9
No files matched your search
@@ -641,6 +641,34 @@ void errlogBufResize(int bufsize, int maxMsgSize)
|
||||
epicsMutexUnlock(pvt.bufSizeLock);
|
||||
}
|
||||
|
||||
void errlogShow(int level)
|
||||
{
|
||||
epicsMutexMustLock(pvt.bufSizeLock);
|
||||
printf("Error log:\n");
|
||||
printf(" buffer size: %zu\n", pvt.bufSize);
|
||||
printf(" max message size: %zu\n", pvt.maxMsgSize);
|
||||
epicsMutexUnlock(pvt.bufSizeLock);
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
epicsMutexMustLock(pvt.listenerLock);
|
||||
printf(" number of listeners: %u\n", pvt.listenerList.count);
|
||||
epicsMutexUnlock(pvt.listenerLock);
|
||||
}
|
||||
|
||||
if (level > 1)
|
||||
{
|
||||
epicsMutexMustLock(pvt.msgQueueLock);
|
||||
printf(" buffer(log) contents:\n");
|
||||
printf("%s\n", pvt.log->base);
|
||||
printf("%*s^\n", (int)pvt.log->pos, "");
|
||||
printf(" buffer(print) contents:\n");
|
||||
printf("%s\n", pvt.print->base);
|
||||
printf("%*s^\n", (int)pvt.print->pos, "");
|
||||
epicsMutexUnlock(pvt.msgQueueLock);
|
||||
}
|
||||
}
|
||||
|
||||
void errlogFlush(void)
|
||||
{
|
||||
/* wait for both buffers to be handled to know that all currently
|
||||
|
||||
@@ -224,15 +224,6 @@ LIBCOM_API int errlogInit(int bufsize);
|
||||
*/
|
||||
LIBCOM_API int errlogInit2(int bufsize, int maxMsgSize);
|
||||
|
||||
/**
|
||||
* errlogBufResize can be used to reinitialize the error logging system with a larger buffer and maximum message size.
|
||||
* The default buffer size is 1280 bytes, and the default maximum message size is 256.
|
||||
*
|
||||
* \param bufsize The desired buffer size
|
||||
* \param maxMsgSize The desired max message size
|
||||
*/
|
||||
LIBCOM_API void errlogBufResize(int bufsize, int maxMsgSize);
|
||||
|
||||
/** Wakes up the errlog task and then waits until all messages are flushed from the queue. */
|
||||
LIBCOM_API void errlogFlush(void);
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2026 European Spallation Source ERIC
|
||||
* SPDX-License-Identifier: EPICS
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
#ifndef INC_errlogPvt_H
|
||||
#define INC_errlogPvt_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* errlogShow is used to display the contents of the error log buffers
|
||||
*
|
||||
* \param level How much detail to print out
|
||||
*/
|
||||
void errlogShow(int level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*INC_errlogPvt_H*/
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "osiUnistd.h"
|
||||
#include "logClient.h"
|
||||
#include "errlog.h"
|
||||
#include "errlogPvt.h"
|
||||
#include "taskwd.h"
|
||||
#include "registry.h"
|
||||
#include "epicsGeneralTime.h"
|
||||
@@ -306,6 +307,21 @@ static void errlogBufResizeCallFunc(const iocshArgBuf *args)
|
||||
errlogBufResize(args[0].ival, args[1].ival);
|
||||
}
|
||||
|
||||
/* errlogShow */
|
||||
static const iocshArg errlogShowArg0 = { "level",iocshArgInt};
|
||||
static const iocshArg * const errlogShowArgs[1] = {&errlogShowArg0};
|
||||
static const iocshFuncDef errlogShowFuncDef = {
|
||||
"errlogShow",1,errlogShowArgs,
|
||||
"Show the contents of the error log private data\n"
|
||||
"level 0 - Show the size of the buffers and max message size\n"
|
||||
" 1 - Show the number of listeners\n"
|
||||
" 2 - Show the contents of the buffer\n"
|
||||
};
|
||||
static void errlogShowCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
errlogShow(args[0].ival);
|
||||
}
|
||||
|
||||
/* errlog */
|
||||
IOCSH_STATIC_FUNC void errlog(const char *message)
|
||||
{
|
||||
@@ -517,6 +533,7 @@ void epicsStdCall libComRegister(void)
|
||||
iocshRegister(&errlogInitFuncDef,errlogInitCallFunc);
|
||||
iocshRegister(&errlogInit2FuncDef,errlogInit2CallFunc);
|
||||
iocshRegister(&errlogBufResizeFuncDef,errlogBufResizeCallFunc);
|
||||
iocshRegister(&errlogShowFuncDef,errlogShowCallFunc);
|
||||
iocshRegister(&errlogFuncDef, errlogCallFunc);
|
||||
iocshRegister(&iocLogPrefixFuncDef, iocLogPrefixCallFunc);
|
||||
|
||||
|
||||
Reference in new issue
Block a user