1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #include "base/context.hpp"
21 #include <boost/thread/tss.hpp>
24 using namespace icinga;
26 static boost::thread_specific_ptr<std::list<String> > l_Frames;
28 ContextFrame::ContextFrame(const String& message)
30 GetFrames().push_front(message);
33 ContextFrame::~ContextFrame()
35 GetFrames().pop_front();
38 std::list<String>& ContextFrame::GetFrames()
41 l_Frames.reset(new std::list<String>());
46 ContextTrace::ContextTrace()
47 : m_Frames(ContextFrame::GetFrames())
50 void ContextTrace::Print(std::ostream& fp) const
58 for (const String& frame : m_Frames) {
59 fp << "\t(" << i << ") " << frame << "\n";
64 size_t ContextTrace::GetLength() const
66 return m_Frames.size();
69 std::ostream& icinga::operator<<(std::ostream& stream, const ContextTrace& trace)