Belle II Software development
LogConnectionJSON.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/logging/LogConnectionJSON.h>
10#include <framework/logging/LogMessage.h>
11#include <boost/property_tree/json_parser.hpp>
12
13namespace Belle2 {
19 LogConnectionJSON::LogConnectionJSON(bool complete): m_console{STDOUT_FILENO, false}, m_complete{complete}
20 {
21 }
22
24 {
25 if (!isConnected()) return false;
26 m_console.write(message.toJSON(m_complete));
27 return true;
28 }
29
31}
void write(const std::string &message)
Send a preformatted string message to the connected output.
LogConnectionConsole m_console
LogConnection to the console we use to dispatch the json objects.
bool m_complete
If true ignore the log message format settings and output everything.
bool isConnected() override
Returns true if the connection to the text file could be established.
The LogMessage class.
Definition: LogMessage.h:29
LogConnectionJSON(bool complete=false)
The constructor.
bool sendMessage(const LogMessage &message) override
Sends a log message.
Abstract base class for different kinds of events.