@@ -814,9 +814,9 @@ void SessionLogMsgFilter::addToPTree(IPropertyTree * tree) const
814
814
tree->addPropTree (" filter" , filterTree);
815
815
}
816
816
817
- bool RegexLogMsgFilter::includeMessage (const LogMsg & msg) const
818
- {
819
- if (localFlag && msg.queryRemoteFlag ()) return false ;
817
+ bool RegexLogMsgFilter::includeMessage (const LogMsg & msg) const
818
+ {
819
+ if (localFlag && msg.queryRemoteFlag ()) return false ;
820
820
SpinBlock b (lock);
821
821
return const_cast <RegExpr &>(regex).find (msg.queryText ()) != NULL ;
822
822
}
@@ -1303,7 +1303,7 @@ void RollingFileLogMsgHandler::doRollover(bool daily, const char *forceName)
1303
1303
}
1304
1304
}
1305
1305
}
1306
- if (!handle)
1306
+ if (!handle)
1307
1307
{
1308
1308
handle = getNullHandle ();
1309
1309
OWARNLOG (" RollingFileLogMsgHandler::doRollover : could not open log file %s for output" , filename.str ());
@@ -1420,9 +1420,9 @@ void LogMsgMonitor::addToPTree(IPropertyTree * tree) const
1420
1420
void CLogMsgManager::MsgProcessor::push (LogMsg * msg)
1421
1421
{
1422
1422
// assertex(more); an assertex will just recurse here
1423
- if (!more) // we are effective stopped so don't bother even dropping (and leak parameter) as drop will involve
1424
- // interaction with the base class which is stopped and could easily crash (as this condition
1425
- // is expected not to occur - typically occurs if the user has incorrectly called exit on one thread
1423
+ if (!more) // we are effective stopped so don't bother even dropping (and leak parameter) as drop will involve
1424
+ // interaction with the base class which is stopped and could easily crash (as this condition
1425
+ // is expected not to occur - typically occurs if the user has incorrectly called exit on one thread
1426
1426
// while still in the process of logging on another)
1427
1427
// cf Bug #53695 for more discussion of the issue
1428
1428
return ;
@@ -1578,14 +1578,14 @@ void CLogMsgManager::enterQueueingMode()
1578
1578
1579
1579
void CLogMsgManager::setQueueBlockingLimit (unsigned lim)
1580
1580
{
1581
- CriticalBlock crit (modeLock);
1581
+ CriticalBlock crit (modeLock);
1582
1582
if (processor)
1583
1583
processor->setBlockingLimit (lim);
1584
1584
}
1585
1585
1586
1586
void CLogMsgManager::setQueueDroppingLimit (unsigned lim, unsigned numToDrop)
1587
1587
{
1588
- CriticalBlock crit (modeLock);
1588
+ CriticalBlock crit (modeLock);
1589
1589
if (processor)
1590
1590
processor->setDroppingLimit (lim, numToDrop);
1591
1591
}
@@ -1925,8 +1925,8 @@ void CLogMsgManager::addAllMonitorsToPTree(IPropertyTree * tree) const
1925
1925
monitors.item (i).addToPTree (tree);
1926
1926
}
1927
1927
1928
- bool CLogMsgManager::rejectsCategory (const LogMsgCategory & cat) const
1929
- {
1928
+ bool CLogMsgManager::rejectsCategory (const LogMsgCategory & cat) const
1929
+ {
1930
1930
if (!prefilter.includeCategory (cat))
1931
1931
return true ;
1932
1932
@@ -2329,7 +2329,6 @@ class CNullManager : implements ILogMsgManager
2329
2329
2330
2330
static CNullManager nullManager;
2331
2331
static Singleton<IRemoteLogAccess> logAccessor;
2332
- static CriticalSection logAccessCrit;
2333
2332
2334
2333
MODULE_INIT (INIT_PRIORITY_JLOG)
2335
2334
{
@@ -2377,6 +2376,7 @@ static constexpr unsigned queueLenDefault = 512;
2377
2376
static constexpr unsigned queueDropDefault = 0 ; // disabled by default
2378
2377
static constexpr bool useSysLogDefault = false ;
2379
2378
2379
+ static CConfigUpdateHook configUpdateHook;
2380
2380
void setupContainerizedLogMsgHandler ()
2381
2381
{
2382
2382
Owned<IPropertyTree> logConfig = getComponentConfigSP ()->getPropTree (" logging" );
@@ -2391,22 +2391,25 @@ void setupContainerizedLogMsgHandler()
2391
2391
if (logConfig->hasProp (logFormatAtt))
2392
2392
{
2393
2393
const char *logFormat = logConfig->queryProp (logFormatAtt);
2394
- bool newFormatDetected = false ;
2394
+ HandleLogMsgHandler *previousStderrHandler{ nullptr } ;
2395
2395
if (streq (logFormat, " xml" ))
2396
2396
{
2397
+ previousStderrHandler = theStderrHandler;
2397
2398
theStderrHandler = new HandleLogMsgHandlerXML (stderr, MSGFIELD_STANDARD);
2398
- newFormatDetected = true ;
2399
2399
}
2400
2400
else if (streq (logFormat, " json" ))
2401
2401
{
2402
+ previousStderrHandler = theStderrHandler;
2402
2403
theStderrHandler = new HandleLogMsgHandlerJSON (stderr, MSGFIELD_STANDARD);
2403
- newFormatDetected = true ;
2404
2404
}
2405
2405
else if (!streq (logFormat, " table" ))
2406
2406
LOG (MCoperatorWarning, " JLog: Invalid log format configuration detected '%s'!" , logFormat);
2407
2407
2408
- if (newFormatDetected)
2408
+ if (previousStderrHandler)
2409
+ {
2409
2410
theManager->resetMonitors ();
2411
+ delete previousStderrHandler;
2412
+ }
2410
2413
}
2411
2414
2412
2415
if (logConfig->hasProp (logFieldsAtt))
@@ -2464,15 +2467,30 @@ void setupContainerizedLogMsgHandler()
2464
2467
unsigned postMortemLines = logConfig->getPropInt (capturePostMortemAtt, 0 );
2465
2468
if (postMortemLines)
2466
2469
{
2470
+ PostMortemLogMsgHandler *previousPostMortemHandler{nullptr };
2471
+ if (thePostMortemHandler)
2472
+ {
2473
+ previousPostMortemHandler = thePostMortemHandler;
2474
+ queryLogMsgManager ()->removeMonitor (thePostMortemHandler);
2475
+ }
2476
+
2467
2477
// augment postmortem files with <pid> to avoid clashes where multiple processes are running within
2468
2478
// same process space, e.g. hthor processes running in same k8s container
2469
2479
unsigned pid = GetCurrentProcessId ();
2470
2480
VStringBuffer portMortemFileBase (" /tmp/postmortem.%u.log" , pid);
2471
2481
2472
2482
thePostMortemHandler = new PostMortemLogMsgHandler (portMortemFileBase, postMortemLines, MSGFIELD_STANDARD);
2473
2483
queryLogMsgManager ()->addMonitor (thePostMortemHandler, getCategoryLogMsgFilter (MSGAUD_all, MSGCLS_all, TopDetail));
2484
+
2485
+ delete previousPostMortemHandler;
2474
2486
}
2475
2487
}
2488
+
2489
+ auto updateConfigFunc = [](const IPropertyTree *oldComponentConfiguration, const IPropertyTree *oldGlobalConfiguration)
2490
+ {
2491
+ setupContainerizedLogMsgHandler ();
2492
+ };
2493
+ configUpdateHook.installOnce (updateConfigFunc, false );
2476
2494
}
2477
2495
2478
2496
ILogMsgManager * queryLogMsgManager ()
@@ -2504,7 +2522,7 @@ ISysLogEventLogger * querySysLogEventLogger()
2504
2522
2505
2523
ILogMsgHandler * getSysLogMsgHandler (unsigned fields)
2506
2524
{
2507
- return new SysLogMsgHandler (theSysLogEventLogger, fields);
2525
+ return new SysLogMsgHandler (theSysLogEventLogger, fields);
2508
2526
}
2509
2527
2510
2528
#ifdef _WIN32
@@ -2555,7 +2573,7 @@ bool CSysLogEventLogger::win32Report(unsigned eventtype, unsigned category, unsi
2555
2573
char src[_MAX_PATH+1 ];
2556
2574
LPTSTR tail;
2557
2575
DWORD res = SearchPath (NULL ," JELOG.DLL" ,NULL ,sizeof (src),src,&tail);
2558
- if (res>0 )
2576
+ if (res>0 )
2559
2577
copyFile (path,src);
2560
2578
else
2561
2579
throw makeOsException (GetLastError ());
@@ -2570,20 +2588,20 @@ bool CSysLogEventLogger::win32Report(unsigned eventtype, unsigned category, unsi
2570
2588
2571
2589
}
2572
2590
HKEY hk;
2573
- if (RegCreateKeyEx (HKEY_LOCAL_MACHINE," SYSTEM\\ CurrentControlSet\\ Services\\ EventLog\\ Application\\ Seisint" ,
2591
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE," SYSTEM\\ CurrentControlSet\\ Services\\ EventLog\\ Application\\ Seisint" ,
2574
2592
NULL , NULL , 0 , KEY_ALL_ACCESS, NULL , &hk, NULL )==0 ) {
2575
2593
DWORD sizedata = 0 ;
2576
2594
DWORD type = REG_EXPAND_SZ;
2577
2595
if ((RegQueryValueEx (hk," EventMessageFile" ,NULL , &type, NULL , &sizedata)!=0 )||!sizedata) {
2578
- StringAttr str (" %SystemRoot%\\ System32\\ JELOG.dll" );
2596
+ StringAttr str (" %SystemRoot%\\ System32\\ JELOG.dll" );
2579
2597
RegSetValueEx (hk," EventMessageFile" , 0 , REG_EXPAND_SZ, (LPBYTE) str.get (), (DWORD)str.length () + 1 );
2580
2598
RegSetValueEx (hk," CategoryMessageFile" , 0 , REG_EXPAND_SZ, (LPBYTE) str.get (), (DWORD)str.length () + 1 );
2581
- DWORD dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE | EVENTLOG_AUDIT_SUCCESS | EVENTLOG_AUDIT_FAILURE;
2599
+ DWORD dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE | EVENTLOG_AUDIT_SUCCESS | EVENTLOG_AUDIT_FAILURE;
2582
2600
RegSetValueEx (hk, " TypesSupported" , 0 , REG_DWORD, (LPBYTE) &dwData, sizeof (DWORD));
2583
2601
dwData = 16 ;
2584
2602
RegSetValueEx (hk, " CategoryCount" , 0 , REG_DWORD, (LPBYTE) &dwData, sizeof (DWORD));
2585
2603
}
2586
- RegCloseKey (hk);
2604
+ RegCloseKey (hk);
2587
2605
}
2588
2606
hEventLog = RegisterEventSource (NULL ," Seisint" );
2589
2607
if (!hEventLog) {
@@ -2621,8 +2639,8 @@ bool CSysLogEventLogger::win32Report(unsigned eventtype, unsigned category, unsi
2621
2639
2622
2640
CSysLogEventLogger::~CSysLogEventLogger ()
2623
2641
{
2624
- if (hEventLog!=0 )
2625
- DeregisterEventSource (hEventLog);
2642
+ if (hEventLog!=0 )
2643
+ DeregisterEventSource (hEventLog);
2626
2644
}
2627
2645
2628
2646
#else
@@ -2631,7 +2649,7 @@ CSysLogEventLogger::~CSysLogEventLogger()
2631
2649
2632
2650
#define CATEGORY_AUDIT_FUNCTION_REQUIRED
2633
2651
#define AUDIT_TYPES_BEGIN int auditTypeDataMap[NUM_AUDIT_TYPES+1 ] = {
2634
- #define MAKE_AUDIT_TYPE (name, type, categoryid, eventid, level ) level,
2652
+ #define MAKE_AUDIT_TYPE (name, type, categoryid, eventid, level ) level,
2635
2653
#define AUDIT_TYPES_END 0 };
2636
2654
#include " jelogtype.hpp"
2637
2655
#undef CATEGORY_AUDIT_FUNCTION_REQUIRED
@@ -2932,7 +2950,7 @@ extern jlib_decl void UseSysLogForOperatorMessages(bool use)
2932
2950
return ;
2933
2951
if (use) {
2934
2952
msgHandler = getSysLogMsgHandler ();
2935
- ILogMsgFilter * operatorFilter = getCategoryLogMsgFilter (MSGAUD_operator, MSGCLS_all, DefaultDetail, true );
2953
+ ILogMsgFilter * operatorFilter = getCategoryLogMsgFilter (MSGAUD_operator, MSGCLS_all, DefaultDetail, true );
2936
2954
queryLogMsgManager ()->addMonitorOwn (msgHandler, operatorFilter);
2937
2955
}
2938
2956
else {
@@ -3435,15 +3453,15 @@ TraceFlags loadTraceFlags(const IPropertyTree *ptree, const std::initializer_lis
3435
3453
return dft;
3436
3454
}
3437
3455
3438
- void ctxlogReport (const LogMsgCategory & cat, const char * format, ...)
3456
+ void ctxlogReport (const LogMsgCategory & cat, const char * format, ...)
3439
3457
{
3440
3458
va_list args;
3441
3459
va_start (args, format);
3442
3460
ctxlogReportVA (cat, NoLogMsgCode, format, args);
3443
3461
va_end (args);
3444
3462
}
3445
3463
3446
- void ctxlogReportVA (const LogMsgCategory & cat, const char * format, va_list args)
3464
+ void ctxlogReportVA (const LogMsgCategory & cat, const char * format, va_list args)
3447
3465
{
3448
3466
ctxlogReportVA (cat, NoLogMsgCode, format, args);
3449
3467
}
0 commit comments