Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

logserver_c.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: logserver_c.cpp,v 1.3 2004/06/13 05:40:37 fruit Exp $
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; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 #include "logserver.h"
00023 #include <fstream>
00024 
00025 using namespace boost;
00026 using namespace zeitgeist;
00027 
00028 FUNCTION(LogServer,addStream)
00029 {
00030     std::string inName;
00031     std::string inPriority;
00032 
00033     if (
00034         (in.GetSize() != 2) ||
00035         (! in.GetValue(in[0],inName)) ||
00036         (! in.GetValue(in[1],inPriority))
00037         )
00038     {
00039         return false;
00040     }
00041 
00042     std::ostream *stream = NULL;
00043     if (inName == ":cout")
00044     {
00045         stream = &std::cout;
00046     } else if (inName == ":cerr")
00047     {
00048         stream = &std::cerr;
00049     } else
00050     {
00051         stream = new std::ofstream(inName.c_str());
00052     }
00053 
00054     unsigned int pLevel = LogServer::eNone;
00055 
00056     do
00057     {
00058         if (inPriority == "eNone")
00059         {
00060             pLevel = LogServer::eNone;
00061             break;
00062         }
00063 
00064         if (inPriority == "eDebug")
00065         {
00066             pLevel = LogServer::eDebug;
00067             break;
00068         }
00069 
00070         if (inPriority == "eNormal")
00071         {
00072             pLevel = LogServer::eNormal;
00073             break;
00074         }
00075 
00076         if (inPriority == "eWarning")
00077         {
00078             pLevel = LogServer::eWarning;
00079             break;
00080         }
00081 
00082         if (inPriority == "eError")
00083         {
00084             pLevel = LogServer::eError;
00085             break;
00086         }
00087 
00088         if (inPriority == "eAll")
00089         {
00090             pLevel = LogServer::eAll;
00091             break;
00092         }
00093 
00094         // no match
00095         return false;
00096 
00097     } while(true);
00098 
00099     obj->AddStream(stream, pLevel);
00100     return true;
00101 }
00102 
00103 void CLASS(LogServer)::DefineClass()
00104 {
00105     DEFINE_BASECLASS(zeitgeist/Node);
00106     DEFINE_FUNCTION(addStream);
00107 }

Generated on Thu Apr 6 15:25:38 2006 for rcssserver3d by  doxygen 1.4.4