Line data Source code
1 : /*
2 : * Copyright (c) 2013-2019 Made to Order Software Corp. All Rights Reserved
3 : *
4 : * https://snapwebsites.org/project/snaplogger
5 : * contact@m2osw.com
6 : *
7 : * This program is free software; you can redistribute it and/or modify
8 : * it under the terms of the GNU General Public License as published by
9 : * the Free Software Foundation; either version 2 of the License, or
10 : * (at your option) any later version.
11 : *
12 : * This program is distributed in the hope that it will be useful,
13 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : * GNU General Public License for more details.
16 : *
17 : * You should have received a copy of the GNU General Public License along
18 : * with this program; if not, write to the Free Software Foundation, Inc.,
19 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 : */
21 : #pragma once
22 :
23 : /** \file
24 : * \brief Define the component class used as a way to group messages.
25 : *
26 : * Whenever you send a log, you can assign a component to it.
27 : *
28 : * By default, when a log component's list is empty, it is view as if
29 : * the list was only composed of the NORMAL component.
30 : */
31 :
32 :
33 : // C++ lib
34 : //
35 : #include <memory>
36 : #include <set>
37 : #include <string>
38 : #include <vector>
39 :
40 :
41 :
42 : namespace snaplogger
43 : {
44 :
45 :
46 : class message;
47 :
48 :
49 6 : class component
50 : {
51 : public:
52 : typedef std::shared_ptr<component> pointer_t;
53 : typedef std::set<pointer_t> set_t;
54 :
55 : component(std::string const & name);
56 :
57 : std::string const & get_name() const;
58 :
59 : private:
60 : std::string const f_name;
61 : };
62 :
63 :
64 :
65 : component::pointer_t get_component(std::string const & name);
66 : component::pointer_t get_component(message const & msg, std::string const & name);
67 :
68 :
69 : constexpr char const COMPONENT_DEBUG[] = "debug";
70 : constexpr char const COMPONENT_NORMAL[] = "normal";
71 : constexpr char const COMPONENT_SECURE[] = "secure";
72 :
73 : extern component::pointer_t g_debug_component;
74 : extern component::pointer_t g_normal_component;
75 : extern component::pointer_t g_secure_component;
76 :
77 :
78 : struct section_ptr
79 : {
80 : component::pointer_t f_component;
81 : };
82 :
83 : inline section_ptr section(component::pointer_t comp)
84 : {
85 : return { comp };
86 : }
87 :
88 :
89 :
90 :
91 :
92 : } // snaplogger namespace
93 : // vim: ts=4 sw=4 et
|