LCOV - code coverage report
Current view: top level - snaplogger - component.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2019-08-13 00:35:33 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.12