36 #define BUFFER_LEN LINE_MAX
53 template <
typename _CharT,
typename _Traits=std::
char_traits<_CharT> >
55 :
public ::std::basic_streambuf<_CharT, _Traits>
84 this->setp(pStart, pEnd);
85 this->setg(pStart, pStart, pEnd);
138 m_streams.push_back(
Stream(stream, cleanup));
165 std::vector<coil::log_streambuf<char>::Stream>::iterator it;
166 for( it = m_streams.begin(); it != m_streams.end(); it++ )
168 if (it->stream_ == stream)
198 std::vector<streambuf_type*> buffs;
199 for (
int i(0), len(m_streams.size()); i < len; ++i)
201 buffs.push_back(m_streams[i].stream_);
229 for (
int i(0), len(m_streams.size()); i < len; ++i)
231 Guard gaurd(m_streams[i].mutex_);
232 m_streams[i].stream_->sputn(s, n);
255 bytes_to_write = this->pptr() - this->gptr();
256 if (bytes_to_write > 0)
258 for (
int i(0), len(m_streams.size()); i < len; ++i)
260 Guard gaurd(m_streams[i].mutex_);
261 m_streams[i].stream_->sputn(this->gptr(), bytes_to_write);
263 this->gbump(bytes_to_write);
264 if (this->gptr() >= this->pptr())
266 this->pbump(this->pbase() - this->pptr());
267 this->gbump(this->pbase() - this->gptr());
270 return bytes_to_write;
296 for (
int i(0), len(m_streams.size()); i < len; ++i)
298 Guard gaurd(m_streams[i].mutex_);
299 m_streams[i].stream_->sputn(s, n);
300 m_streams[i].stream_->pubsync();
324 Guard guard(m_mutex);
336 if (this->pptr() > this->epptr() || this->pptr() < this->pbase())
337 return traits_type::eof();
339 if (!traits_type::eq_int_type(c, traits_type::eof()))
342 *(this->pptr()) = traits_type::to_char_type(c);
346 int bytes_to_write = this->pptr() - this->gptr();
348 if (bytes_to_write > 0)
350 if (
stream_sputn(this->gptr(), bytes_to_write) != bytes_to_write)
351 return traits_type::eof();
353 this->pbump(this->pbase() - this->pptr());
354 this->gbump(this->pbase() - this->gptr());
358 else if (!traits_type::eq_int_type(c, traits_type::eof()))
361 char_type last_char = traits_type::to_char_type(c);
364 return traits_type::eof();
368 if (traits_type::eq_int_type(c, traits_type::eof()))
369 return traits_type::not_eof(c);
393 Guard guard(m_mutex);
394 if (this->pptr() > this->epptr() || this->pptr() < this->pbase())
398 bytes_to_write = this->pptr() - this->gptr();
399 if (bytes_to_write > 0)
401 if (
stream_sputn(this->gptr(), bytes_to_write) != bytes_to_write)
405 this->gbump(bytes_to_write);
406 if (this->gptr() >= this->pptr())
408 this->pbump(this->pbase() - this->pptr());
409 this->gbump(this->pbase() - this->gptr());
520 std::vector<Stream> m_streams;
539 template <
typename _CharT,
typename _Traits=std::
char_traits<_CharT> >
541 :
public std::basic_ostream<_CharT, _Traits>
579 m_minLevel(levelmin), m_maxLevel(levelmax), m_logLevel(level)
581 if (m_minLevel >= m_maxLevel)
throw std::bad_alloc();
629 if (m_minLevel <= level && level <= m_maxLevel)
734 if (m_minLevel <= level && level <= m_logLevel)
771 return m_minLevel <= level && level <= m_logLevel;
894 int m_minLevel, m_maxLevel;
904 std::ofstream m_dummy;
926 template <
typename _CharT,
typename _Traits >
929 template <
typename _CharT,
typename _Traits >