/*
-Copyright (c) 2004-2009, John Hurst
+Copyright (c) 2004-2011, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
void
Kumu::EntryListLogSink::WriteEntry(const LogEntry& Entry)
{
- AutoMutex L(m_Lock);
+ AutoMutex L(m_lock);
+ WriteEntryToListeners(Entry);
if ( Entry.TestFilter(m_filter) )
m_Target.push_back(Entry);
void
Kumu::StdioLogSink::WriteEntry(const LogEntry& Entry)
{
- AutoMutex L(m_Lock);
std::string buf;
+ AutoMutex L(m_lock);
+ WriteEntryToListeners(Entry);
if ( Entry.TestFilter(m_filter) )
{
Entry.CreateStringWithOptions(buf, m_options);
fputs(buf.c_str(), m_stream);
+ fflush(m_stream);
}
}
void
Kumu::WinDbgLogSink::WriteEntry(const LogEntry& Entry)
{
- AutoMutex L(m_Lock);
std::string buf;
+ AutoMutex L(m_lock);
+ WriteEntryToListeners(Entry);
if ( Entry.TestFilter(m_filter) )
{
Entry.CreateStringWithOptions(buf, m_options);
- int lenW = ::MultiByteToWideChar(CP_ACP, 0, buf.c_str(), buf.size(), 0, 0);
-
- if ( lenW > 0 )
- {
- // Check whether conversion was successful
- BSTR unicodestr = ::SysAllocStringLen(0, lenW);
- ::MultiByteToWideChar(CP_ACP, 0, buf.c_str(), buf.size(), unicodestr, lenW);
- ::OutputDebugString(unicodestr);
- ::SysFreeString(unicodestr);
- }
- else
- {
- ::OutputDebugString(L("MultiByteToWideChar failed, log sink output discarded.\n"));
- }
+ ::OutputDebugStringA(buf.c_str());
}
}
#endif
void
Kumu::StreamLogSink::WriteEntry(const LogEntry& Entry)
{
- AutoMutex L(m_Lock);
std::string buf;
+ AutoMutex L(m_lock);
+ WriteEntryToListeners(Entry);
if ( Entry.TestFilter(m_filter) )
{
Entry.CreateStringWithOptions(buf, m_options);
- write(m_fd, buf.c_str(), buf.size());
+ ssize_t n = write(m_fd, buf.c_str(), buf.size());
+ assert(n==buf.size());
}
}
case Kumu::LOG_DEBUG: priority = SYSLOG_DEBUG; break;
}
- AutoMutex L(m_Lock);
+ AutoMutex L(m_lock);
+ WriteEntryToListeners(Entry);
if ( Entry.TestFilter(m_filter) )
{