Planeshift

consoleout.h

Go to the documentation of this file.
00001 /*
00002  * consoleout.h - author: Matze Braun <[email protected]>
00003  *
00004  * Copyright (C) 2001 Atomic Blue ([email protected], http://www.atomicblue.org) 
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 #ifndef __CONSOLEOUT_H__
00020 #define __CONSOLEOUT_H__
00021 
00022 #include <stdarg.h>
00023 
00024 #include <csutil/csstring.h>
00025 
00030 extern FILE * errorLog;
00031 
00035 enum ConsoleOutMsgClass
00036 {
00037   CON_NONE = 0,        // No output.
00038   CON_CMDOUTPUT,       // Used for server command output. Is always displayed.
00039   CON_BUG,             // A bug. Very important to show.
00040   CON_ERROR,           // Error
00041   CON_WARNING,         // Warning
00042   CON_NOTIFY,          // Notification
00043   CON_DEBUG,           // Debugging message
00044   CON_SPAM             // High volume spam used for detailed logging
00045 };
00046 
00050 class ConsoleOut
00051 {
00052 public:
00056     static void Intern_Printf(ConsoleOutMsgClass con, const char *arg, ...);
00057 
00061     static void Intern_VPrintf(ConsoleOutMsgClass con, const char *arg, va_list ap);
00062 
00067     static void Intern_Printf_LogOnly(ConsoleOutMsgClass con,
00068         const char *arg, ...);
00069 
00074     static void Intern_VPrintf_LogOnly(ConsoleOutMsgClass con,
00075         const char *arg, va_list args);
00076 
00082     static void SetOutputFile (const char* filename, bool append);
00083 
00089     static void SetMaximumOutputClassStdout (ConsoleOutMsgClass con);
00090 
00096     static void SetMaximumOutputClassFile (ConsoleOutMsgClass con);
00097 
00103     static void SetStringBuffer(csString *buffer)
00104     {
00105         strBuffer = buffer;
00106         if (buffer)
00107             buffer->Clear();
00108     }
00109 
00113     static void SetPrompt(const char*format, ...);
00114 
00115     static ConsoleOutMsgClass GetMaximumOutputClassStdout();
00116     static ConsoleOutMsgClass GetMaximumOutputClassFile();
00117     
00118     static void Shift();
00119     static void Unshift();
00120     
00121     static int shift;
00122     static csString *strBuffer;
00123     static bool atStartOfLine;
00124     static bool promptDisplayed;
00125 };
00126 
00130 #define CPrintf         ConsoleOut::Intern_Printf
00131 #define CVPrintf        ConsoleOut::Intern_VPrintf
00132 #define CPrintfLog      ConsoleOut::Intern_Printf_LogOnly
00133 #define CVPrintfLog     ConsoleOut::Intern_VPrintf_LogOnly
00134 #define CShift          ConsoleOut::Shift
00135 #define CUnshift        ConsoleOut::Unshift
00136 #define CPrompt         ConsoleOut::SetPrompt
00137 
00140 #endif
00141