Skip to content

Commit 92be2db

Browse files
Merge remote-tracking branch 'origin/master' into kafka-zookeeper
2 parents 9439899 + 3319a5e commit 92be2db

File tree

162 files changed

+1589
-845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+1589
-845
lines changed

base/poco/Foundation/include/Poco/ErrorHandler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "Poco/Exception.h"
2222
#include "Poco/Foundation.h"
2323
#include "Poco/Mutex.h"
24+
#include "Poco/Message.h"
2425

2526

2627
namespace Poco
@@ -78,6 +79,10 @@ class Foundation_API ErrorHandler
7879
///
7980
/// The default implementation just breaks into the debugger.
8081

82+
virtual void logMessageImpl(Message::Priority priority, const std::string & msg) {}
83+
/// Write a messages to the log
84+
/// Useful for logging from Poco
85+
8186
static void handle(const Exception & exc);
8287
/// Invokes the currently registered ErrorHandler.
8388

@@ -87,6 +92,9 @@ class Foundation_API ErrorHandler
8792
static void handle();
8893
/// Invokes the currently registered ErrorHandler.
8994

95+
static void logMessage(Message::Priority priority, const std::string & msg);
96+
/// Invokes the currently registered ErrorHandler to log a message.
97+
9098
static ErrorHandler * set(ErrorHandler * pHandler);
9199
/// Registers the given handler as the current error handler.
92100
///

base/poco/Foundation/src/ErrorHandler.cpp

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
99
// and Contributors.
1010
//
11-
// SPDX-License-Identifier: BSL-1.0
11+
// SPDX-License-Identifier: BSL-1.0
1212
//
1313

1414

@@ -35,79 +35,91 @@ ErrorHandler::~ErrorHandler()
3535

3636
void ErrorHandler::exception(const Exception& exc)
3737
{
38-
poco_debugger_msg(exc.what());
38+
poco_debugger_msg(exc.what());
3939
}
4040

41-
41+
4242
void ErrorHandler::exception(const std::exception& exc)
4343
{
44-
poco_debugger_msg(exc.what());
44+
poco_debugger_msg(exc.what());
4545
}
4646

4747

4848
void ErrorHandler::exception()
4949
{
50-
poco_debugger_msg("unknown exception");
50+
poco_debugger_msg("unknown exception");
5151
}
5252

5353

5454
void ErrorHandler::handle(const Exception& exc)
5555
{
56-
FastMutex::ScopedLock lock(_mutex);
57-
try
58-
{
59-
_pHandler->exception(exc);
60-
}
61-
catch (...)
62-
{
63-
}
56+
FastMutex::ScopedLock lock(_mutex);
57+
try
58+
{
59+
_pHandler->exception(exc);
60+
}
61+
catch (...)
62+
{
63+
}
6464
}
6565

66-
66+
6767
void ErrorHandler::handle(const std::exception& exc)
6868
{
69-
FastMutex::ScopedLock lock(_mutex);
70-
try
71-
{
72-
_pHandler->exception(exc);
73-
}
74-
catch (...)
75-
{
76-
}
69+
FastMutex::ScopedLock lock(_mutex);
70+
try
71+
{
72+
_pHandler->exception(exc);
73+
}
74+
catch (...)
75+
{
76+
}
7777
}
7878

7979

8080
void ErrorHandler::handle()
8181
{
82-
FastMutex::ScopedLock lock(_mutex);
83-
try
84-
{
85-
_pHandler->exception();
86-
}
87-
catch (...)
88-
{
89-
}
82+
FastMutex::ScopedLock lock(_mutex);
83+
try
84+
{
85+
_pHandler->exception();
86+
}
87+
catch (...)
88+
{
89+
}
90+
}
91+
92+
void ErrorHandler::logMessage(Message::Priority priority, const std::string & msg)
93+
{
94+
FastMutex::ScopedLock lock(_mutex);
95+
try
96+
{
97+
_pHandler->logMessageImpl(priority, msg);
98+
}
99+
catch (...)
100+
{
101+
}
90102
}
91103

92104

93105
ErrorHandler* ErrorHandler::set(ErrorHandler* pHandler)
94106
{
95-
poco_check_ptr(pHandler);
107+
poco_check_ptr(pHandler);
96108

97-
FastMutex::ScopedLock lock(_mutex);
98-
ErrorHandler* pOld = _pHandler;
99-
_pHandler = pHandler;
100-
return pOld;
109+
FastMutex::ScopedLock lock(_mutex);
110+
ErrorHandler* pOld = _pHandler;
111+
_pHandler = pHandler;
112+
return pOld;
101113
}
102114

103115

104116
ErrorHandler* ErrorHandler::defaultHandler()
105117
{
106-
// NOTE: Since this is called to initialize the static _pHandler
107-
// variable, sh has to be a local static, otherwise we run
108-
// into static initialization order issues.
109-
static SingletonHolder<ErrorHandler> sh;
110-
return sh.get();
118+
// NOTE: Since this is called to initialize the static _pHandler
119+
// variable, sh has to be a local static, otherwise we run
120+
// into static initialization order issues.
121+
static SingletonHolder<ErrorHandler> sh;
122+
return sh.get();
111123
}
112124

113125

base/poco/Net/src/SocketImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Poco/Net/StreamSocketImpl.h"
1818
#include "Poco/NumberFormatter.h"
1919
#include "Poco/Timestamp.h"
20+
#include "Poco/ErrorHandler.h"
2021
#include <string.h> // FD_SET needs memset on some platforms, so we can't use <cstring>
2122

2223

0 commit comments

Comments
 (0)