LCOV - code coverage report
Current view: top level - log - output_option.cc (source / functions) Hit Total Coverage
Test: report.info Lines: 12 12 100.0 %
Date: 2012-05-15 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 21 32 65.6 %

           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                 :            : 
      17                 :            : #include <boost/algorithm/string.hpp>
      18                 :            : 
      19                 :            : #include <log/log_messages.h>
      20                 :            : #include <log/macros.h>
      21                 :            : #include <log/output_option.h>
      22                 :            : 
      23                 :            : namespace isc {
      24                 :            : namespace log {
      25                 :            : 
      26                 :            : OutputOption::Destination
      27                 :         10 : getDestination(const std::string& dest_str) {
      28         [ +  + ]:         20 :     if (boost::iequals(dest_str, "console")) {
      29                 :            :         return OutputOption::DEST_CONSOLE;
      30         [ +  + ]:         14 :     } else if (boost::iequals(dest_str, "file")) {
      31                 :            :         return OutputOption::DEST_FILE;
      32 [ +  - ][ +  + ]:          4 :     } else if (boost::iequals(dest_str, "syslog")) {
      33                 :            :         return OutputOption::DEST_SYSLOG;
      34                 :            :     } else {
      35                 :         11 :         Logger logger("log");
      36 [ +  - ][ +  - ]:          2 :         LOG_ERROR(logger, LOG_BAD_DESTINATION).arg(dest_str);
         [ +  - ][ +  - ]
      37                 :            :         return OutputOption::DEST_CONSOLE;
      38                 :            :     }
      39                 :            : }
      40                 :            : 
      41                 :            : OutputOption::Stream
      42                 :          8 : getStream(const std::string& stream_str) {
      43 [ +  - ][ +  + ]:          8 :     if (boost::iequals(stream_str, "stderr")) {
      44                 :            :         return OutputOption::STR_STDERR;
      45 [ +  - ][ +  + ]:          5 :     } else if (boost::iequals(stream_str, "stdout")) {
      46                 :            :         return OutputOption::STR_STDOUT;
      47                 :            :     } else {
      48                 :         10 :         Logger logger("log");
      49 [ +  - ][ +  - ]:          4 :         LOG_ERROR(logger, LOG_BAD_STREAM).arg(stream_str);
         [ +  - ][ +  - ]
      50                 :            :         return OutputOption::STR_STDOUT;
      51                 :            :     }
      52                 :            : }
      53                 :            : 
      54                 :            : } // namespace log
      55                 :        141 : } // namespace isc

Generated by: LCOV version 1.9