LCOV - code coverage report
Current view: top level - snaplogger - environment.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2021-10-14 20:12:47 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2013-2021  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/snaplogger
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License along
      17             : // with this program; if not, write to the Free Software Foundation, Inc.,
      18             : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             : #pragma once
      20             : 
      21             : /** \file
      22             :  * \brief Environments from where a SNAP_LOG_... is used.
      23             :  *
      24             :  * Whenever you generate a log, the environment from that point in time
      25             :  * is registered in your message. This is very important since a log
      26             :  * can be handled by a different thread or even a different computer
      27             :  * and the appenders have to have the ability to show the PID, GID,
      28             :  * user name, group name, etc. from the original process and not
      29             :  * from the process that actually runs the appenders.
      30             :  */
      31             : 
      32             : // self
      33             : //
      34             : 
      35             : 
      36             : // C++ lib
      37             : //
      38             : #include    <memory>
      39             : #include    <string>
      40             : 
      41             : 
      42             : // C lib
      43             : //
      44             : #include    <unistd.h>
      45             : 
      46             : 
      47             : 
      48             : namespace snaplogger
      49             : {
      50             : 
      51             : 
      52           2 : class environment
      53             : {
      54             : public:
      55             :     typedef std::shared_ptr<environment>     pointer_t;
      56             : 
      57             :                         environment(pid_t tid);
      58             : 
      59             :     uid_t               get_uid() const;
      60             :     pid_t               get_pid() const;
      61             :     gid_t               get_gid() const;
      62             :     pid_t               get_tid() const;
      63             :     std::string         get_username() const;
      64             :     std::string         get_groupname() const;
      65             :     std::string         get_hostname() const;
      66             :     std::string         get_domainname() const;
      67             :     std::string         get_progname() const;
      68             :     std::string         get_threadname() const;
      69             :     std::string         get_boot_id() const;
      70             : 
      71             : private:
      72             :     uid_t               f_uid = -1;
      73             :     pid_t               f_pid = -1;
      74             :     gid_t               f_gid = -1;
      75             :     pid_t               f_tid = -1;
      76             :     std::string         f_username = std::string();
      77             :     std::string         f_groupname = std::string();
      78             :     std::string         f_hostname = std::string();
      79             :     std::string         f_domainname = std::string();
      80             :     std::string         f_progname = std::string();
      81             :     std::string         f_threadname = std::string();
      82             :     std::string         f_boot_id = std::string();
      83             : };
      84             : 
      85             : 
      86             : environment::pointer_t  create_environment();
      87             : 
      88             : 
      89             : } // snaplogger namespace
      90             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13