LCOV - code coverage report
Current view: top level - log - logger_name.cc (source / functions) Hit Total Coverage
Test: report.info Lines: 13 13 100.0 %
Date: 2012-05-15 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 30 63.3 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
       2                 :            : //
       3                 :            : // Permission to use, copy, modify, and/or distribute this software for any
       4                 :            : // purpose with or without fee is hereby granted, provided that the above
       5                 :            : // copyright notice and this permission notice appear in all copies.
       6                 :            : //
       7                 :            : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
       8                 :            : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       9                 :            : // AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
      10                 :            : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      11                 :            : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
      12                 :            : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      13                 :            : // PERFORMANCE OF THIS SOFTWARE.
      14                 :            : 
      15                 :            : #include <string>
      16                 :            : #include "log/logger_name.h"
      17                 :            : 
      18                 :            : namespace isc {
      19                 :            : namespace log {
      20                 :            : 
      21                 :            : namespace {
      22                 :            : 
      23                 :            : // Obtain the root logger name in a way that is safe for statically-initialized
      24                 :            : // objects.
      25                 :            : 
      26                 :            : std::string&
      27                 :       1181 : getRootLoggerNameInternal() {
      28 [ +  + ][ +  - ]:       1282 :     static std::string root_name;
      29                 :       1181 :     return (root_name);
      30                 :            : }
      31                 :            : 
      32                 :            : } // Anonymous namespace
      33                 :            : 
      34                 :            : void
      35                 :        176 : setRootLoggerName(const std::string& name) {
      36                 :        176 :     getRootLoggerNameInternal() = name;
      37                 :        176 : }
      38                 :            : 
      39                 :       1005 : const std::string& getRootLoggerName() {
      40                 :       1005 :     return (getRootLoggerNameInternal());
      41                 :            : }
      42                 :            : 
      43                 :        234 : std::string expandLoggerName(const std::string& name) {
      44                 :            : 
      45                 :            :     // Are we the root logger, or does the logger name start with
      46                 :            :     // the string "<root_logger_name>.".  If so, use a logger
      47                 :            :     // whose name is the one given.
      48 [ +  - ][ +  + ]:        867 :     if ((name == getRootLoggerName()) ||
         [ +  + ][ +  + ]
      49 [ +  - ][ +  - ]:        399 :         (name.find(getRootLoggerName() + std::string(".")) == 0)) {
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
         [ #  # ][ #  # ]
      50                 :         70 :         return (name);
      51                 :            : 
      52                 :            :     } 
      53                 :            : 
      54                 :            :     // Anything else is assumed to be a sub-logger of the root logger.
      55         [ +  - ]:        398 :     return (getRootLoggerName() + "." + name);
      56                 :            : }
      57                 :            : 
      58                 :            : } // namespace log
      59                 :            : } // namespace isc

Generated by: LCOV version 1.9