hs.hsadmin/hsacppcli/hsadminc/source/logger.h

69 lines
2.6 KiB
C
Raw Normal View History

/***************************************************************************
* Copyright (C) 2005 by Christof Donat *
* cdonat@gmx.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef HSADMIN_LOGGER
#define HSADMIN_LOGGER
#include <string>
#include <stdarg.h>
//! a simple logger
namespace Logger {
extern const int FATAL;
extern const int ERROR;
extern const int WARNING;
extern const int DEBUG;
extern const int XML;
extern int levels[6];
extern int level;
typedef enum {
CouldNotOpenFile = 1001,
NoBodyInResponse = 1002,
CantResolveHostname = 1003,
CantOpenSocket = 1004,
CantConnetcToHost = 1005,
ServerErrorCode = 1006,
UnknownCallbackInXMLParser = 1007,
ConnectionFailed = 1008,
ErrorWithTicketCommand = 1009,
ErrorReadingTicket = 1010
} message;
//! change the loglevel - used by VerbosityOption
void setLevel(int newlevel);
//! increment the loglevel - used by VerbosityOption
void incrementLevel();
//! decrement theloglevel - used by QuietOption
void decrementLevel();
//! do actualy output loginfo
void log(int type, const std::string text);
//! get a message format string for a defined Message Type; use boost::format to insert Values
std::string getMessageFormatString(const message msg);
//! get an appropriate Message for an errno.
std::string getErrnoMessage(int e);
};
#endif /* HSADMIN_LOGGER */