Goby3
3.1.5a
2024.05.23
json_log_plugin.h
Go to the documentation of this file.
1
// Copyright 2016-2022:
2
// GobySoft, LLC (2013-)
3
// Community contributors (see AUTHORS file)
4
// File authors:
5
// Toby Schneider <toby@gobysoft.org>
6
//
7
//
8
// This file is part of the Goby Underwater Autonomy Project Libraries
9
// ("The Goby Libraries").
10
//
11
// The Goby Libraries are free software: you can redistribute them and/or modify
12
// them under the terms of the GNU Lesser General Public License as published by
13
// the Free Software Foundation, either version 2.1 of the License, or
14
// (at your option) any later version.
15
//
16
// The Goby Libraries are distributed in the hope that they will be useful,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
// GNU Lesser General Public License for more details.
20
//
21
// You should have received a copy of the GNU Lesser General Public License
22
// along with Goby. If not, see <http://www.gnu.org/licenses/>.
23
24
#ifndef GOBY_MIDDLEWARE_LOG_JSON_LOG_PLUGIN_H
25
#define GOBY_MIDDLEWARE_LOG_JSON_LOG_PLUGIN_H
26
27
#include "
goby/middleware/log.h
"
28
#include "
goby/middleware/marshalling/json.h
"
29
#include "
goby/middleware/protobuf/log_tool_config.pb.h
"
30
#include "
goby/time/convert.h
"
31
#include "
log_plugin.h
"
32
33
namespace
goby
34
{
35
namespace
middleware
36
{
37
namespace
log
38
{
39
class
JSONPlugin
:
public
LogPlugin
40
{
41
public
:
42
std::string
debug_text_message
(
LogEntry
& log_entry)
override
43
{
44
return
parse_message
(log_entry)->dump();
45
}
46
47
std::shared_ptr<nlohmann::json>
json_message
(
LogEntry
& log_entry)
override
48
{
49
return
parse_message
(log_entry);
50
}
51
52
void
register_read_hooks
(
const
std::ifstream& in_log_file)
override
{}
53
54
void
register_write_hooks
(std::ofstream& out_log_file)
override
{}
55
56
std::shared_ptr<nlohmann::json>
parse_message
(
LogEntry
& log_entry)
57
{
58
const
auto
& data = log_entry.
data
();
59
auto
bytes_begin = data.begin(), bytes_end = data.end(), actual_end = data.begin();
60
return
SerializerParserHelper
<
nlohmann::json
,
61
goby::middleware::MarshallingScheme::JSON
>::parse(bytes_begin,
62
bytes_end,
63
actual_end);
64
}
65
};
66
67
}
// namespace log
68
}
// namespace middleware
69
}
// namespace goby
70
71
#endif
goby
The global namespace for the Goby project.
Definition:
acomms_constants.h:33
goby::middleware::SerializerParserHelper
Class for parsing and serializing a given marshalling scheme. Must be specialized for a particular sc...
Definition:
interface.h:97
goby::middleware::log::LogEntry
Definition:
log_entry.h:99
log_tool_config.pb.h
goby::middleware::log::JSONPlugin::register_write_hooks
void register_write_hooks(std::ofstream &out_log_file) override
Definition:
json_log_plugin.h:54
goby::middleware::log::JSONPlugin::parse_message
std::shared_ptr< nlohmann::json > parse_message(LogEntry &log_entry)
Definition:
json_log_plugin.h:56
goby::middleware::log::JSONPlugin::register_read_hooks
void register_read_hooks(const std::ifstream &in_log_file) override
Definition:
json_log_plugin.h:52
goby::middleware::log::JSONPlugin
Definition:
json_log_plugin.h:39
goby::middleware::log::JSONPlugin::json_message
std::shared_ptr< nlohmann::json > json_message(LogEntry &log_entry) override
Definition:
json_log_plugin.h:47
log_plugin.h
goby::middleware::log::LogEntry::data
const std::vector< unsigned char > & data() const
Definition:
log_entry.h:148
convert.h
log.h
goby::middleware::MarshallingScheme::JSON
@ JSON
Definition:
interface.h:59
json
basic_json<> json
default specialization
Definition:
json.hpp:3404
goby::middleware::log::LogPlugin
Definition:
log_plugin.h:40
json.h
goby::middleware::log::JSONPlugin::debug_text_message
std::string debug_text_message(LogEntry &log_entry) override
Definition:
json_log_plugin.h:42
goby
middleware
log
json_log_plugin.h
Generated by
1.8.17