Note: Goby version 1 (shown here) is now considered obsolete. Please use version 2 for new projects, and consider upgrading old projects.

Goby Underwater Autonomy Project  Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
util/liblogger/logger_manipulators.cpp
00001 // copyright 2009 t. schneider tes@mit.edu
00002 // ocean engineering graudate student - mit / whoi joint program
00003 // massachusetts institute of technology (mit)
00004 // laboratory for autonomous marine sensing systems (lamss)
00005 // 
00006 // this file is part of goby-logger,
00007 // the goby logging library
00008 //
00009 // This program is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // This software is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this software.  If not, see <http://www.gnu.org/licenses/>.
00021 
00022 #include "logger_manipulators.h"
00023 #include "flex_ostream.h"
00024 #include "goby/util/time.h"
00025 
00026 std::ostream & operator<< (std::ostream& os, const Group & g)
00027 {
00028     os << "description: " << g.description() << std::endl;
00029     os << "color: " << goby::util::TermColor::str_from_col(g.color());
00030     return os;
00031 }
00032 
00033 void GroupSetter::operator()(goby::util::FlexOstream& os) const
00034 {    
00035     os.set_group(group_);
00036 }
00037 
00038 void GroupSetter::operator()(std::ostream& os) const
00039 {
00040     try
00041     {
00042         goby::util::FlexOstream& flex = dynamic_cast<goby::util::FlexOstream&>(os);
00043         flex.set_group(group_);
00044     }
00045     catch(...)
00046     {
00047         basic_log_header(os, group_);
00048     }
00049 }
00050 
00051 std::ostream& basic_log_header(std::ostream& os, const std::string& group_name)
00052 {
00053     return os << "[ " << goby::util::goby_time_as_string() << " ] "
00054               << std::setw(15) << "{" << group_name << "}: ";
00055 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends