Belle II Software  release-05-02-19
LogConnectionJSON.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/logging/LogConnectionJSON.h>
12 #include <framework/logging/LogMessage.h>
13 #include <boost/property_tree/json_parser.hpp>
14 
15 namespace Belle2 {
21  LogConnectionJSON::LogConnectionJSON(bool complete): m_console{STDOUT_FILENO, false}, m_complete{complete}
22  {
23  }
24 
25  bool LogConnectionJSON::sendMessage(const LogMessage& message)
26  {
27  if (!isConnected()) return false;
28  m_console.write(message.toJSON(m_complete));
29  return true;
30  }
31 
33 }
Belle2::LogConnectionJSON::isConnected
bool isConnected() override
Returns true if the connection to the text file could be established.
Definition: LogConnectionJSON.h:60
Belle2::LogConnectionJSON::m_console
LogConnectionConsole m_console
LogConnection to the console we use to dispatch the json objects.
Definition: LogConnectionJSON.h:70
Belle2::LogConnectionJSON::m_complete
bool m_complete
If true ignore the log message format settings and output everything.
Definition: LogConnectionJSON.h:72
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogConnectionJSON::LogConnectionJSON
LogConnectionJSON(bool complete=false)
The constructor.
Definition: LogConnectionJSON.cc:29
Belle2::LogConnectionConsole::write
void write(const std::string &message)
Send a preformatted string message to the connected output.
Definition: LogConnectionConsole.cc:55
Belle2::LogConnectionJSON::sendMessage
bool sendMessage(const LogMessage &message) override
Sends a log message.
Definition: LogConnectionJSON.cc:33