libadc-cxx 1.0.0
Structured logging for scientific computing
Loading...
Searching...
No Matches
libadiak_json.ipp
Go to the documentation of this file.
3#include <cstdlib>
4#include "adiak.hpp"
5
6namespace adc {
7
8std::map< const std::string, const std::string> libadiak_json_defaults;
9
10/*! \brief Terminal output publisher_api implementation.
11 This plugin sends messages to libadiak synchronously.
12 Multiple independent instances of this plugin may be used simultaneously,
13 but message integrity depends on the behavior of libadiak.
14 */
16 enum state {
17 ok,
18 err
19 };
20
21private:
22 const std::string vers;
23 const std::vector<std::string> tags;
24 enum state state;
25 bool paused;
26
27public:
28 libadiak_json_plugin() : vers("1.0.0") , tags({"none"}), state(ok), paused(false) {
29 std::cout << "Constructing libadiak_json_plugin" << std::endl;
30 }
31
32 int publish(std::shared_ptr<builder_api> b) {
33 if (paused)
34 return 0;
35 if (state != ok)
36 return 1;
37 auto jstr = b->serialize();
38 adiak::value("adc_event", adiak::jsonstring(jstr));
39 return 0;
40 }
41
42 int config(const std::map< std::string, std::string >& m) {
43 return 0;
44 }
45
46 int config(const std::map< std::string, std::string >& m, std::string_view env_prefix) {
47 return 0;
48 }
49
50 const std::map< const std::string, const std::string> & get_option_defaults() {
52 }
53
54 int initialize() {
55 return 0;
56 }
57
58 void finalize() {
59 }
60
61 void pause() {
62 paused = true;
63 }
64
65 void resume() {
66 paused = false;
67 }
68
69 std::string_view name() const {
70 return "libadiak_json";
71 }
72
73 std::string_view version() const {
74 return vers;
75 }
76
78 std::cout << "Destructing libadiak_json_plugin" << std::endl;
79 }
80};
81
82
83} // adc
Terminal output publisher_api implementation. This plugin sends messages to libadiak synchronously....
std::string_view name() const
const std::map< const std::string, const std::string > & get_option_defaults()
Look up the settable options and their defaults.
int config(const std::map< std::string, std::string > &m, std::string_view env_prefix)
Configure the plugin with the options given and the corresponding environment variables.
int config(const std::map< std::string, std::string > &m)
Configure the plugin with the options given.
void finalize()
Stop publishing and release any resources held for managing publication.
void resume()
Resume publishing Duplicate calls are allowed.
std::string_view version() const
int initialize()
Ready the plugin to publish following the configuration options set or defaulted.
int publish(std::shared_ptr< builder_api > b)
Publish the content of the builder.
void pause()
Pause publishing until a call to resume. Duplicate calls are allowed.
Publisher plugin interface.
Definition publisher.hpp:44
Definition adc.hpp:75
std::map< const std::string, const std::string > libadiak_json_defaults