truebrain@9851: /* $Id$ */ truebrain@9851: truebrain@9851: /** @file ai_log.hpp Everything to handle and issue log messages. */ truebrain@9851: truebrain@9851: #ifndef AI_LOG_HPP truebrain@9851: #define AI_LOG_HPP truebrain@9851: truebrain@9851: #include "ai_object.hpp" truebrain@9851: truebrain@9851: /** truebrain@9851: * Class that handles all log related functions. truebrain@9851: */ truebrain@9851: class AILog : public AIObject { truebrain@9851: /* AIController needs access to Enum and Log, in order to keep the flow from truebrain@9851: * OpenTTD core to NoAI API clear and simple. */ truebrain@9851: friend class AIController; truebrain@9851: truebrain@9851: public: truebrain@9851: static const char *GetClassName() { return "AILog"; } truebrain@9851: truebrain@9851: /** truebrain@9851: * Log levels; The value is also feed to DEBUG() lvl. truebrain@9851: * This has no use for you, as AI writer. truebrain@9851: */ truebrain@9851: enum AILogType { truebrain@9851: LOG_SQ_ERROR = 0, //!< Squirrel printed an error. truebrain@9851: LOG_ERROR = 1, //!< User printed an error. truebrain@9851: LOG_SQ_INFO = 2, //!< Squirrel printed some info. truebrain@9851: LOG_WARNING = 3, //!< User printed some warning. truebrain@9851: LOG_INFO = 4, //!< User printed some info. truebrain@9851: }; truebrain@9851: truebrain@9854: /** truebrain@9854: * Internal representation of the log-data inside the AI. truebrain@9854: * This has no use for you, as AI writer. truebrain@9854: */ truebrain@9851: struct LogData { truebrain@9851: char **lines; truebrain@9851: AILog::AILogType *type; truebrain@9851: int count; truebrain@9851: int pos; truebrain@9851: }; truebrain@9851: truebrain@9851: /** truebrain@9851: * Print an Info message to the logs. truebrain@9851: * @param message The message to log. truebrain@9851: */ truebrain@9851: static void Info(const char *message); truebrain@9851: truebrain@9851: /** truebrain@9851: * Print a Warning message to the logs. truebrain@9851: * @param message The message to log. truebrain@9851: */ truebrain@9851: static void Warning(const char *message); truebrain@9851: truebrain@9851: /** truebrain@9851: * Print an Error message to the logs. truebrain@9851: * @param message The message to log. truebrain@9851: */ truebrain@9851: static void Error(const char *message); truebrain@9851: truebrain@9851: /** truebrain@9851: * Free the log pointer. truebrain@9851: * @note DO NOT CALL YOURSELF; leave it to the internal AI programming. truebrain@9851: */ truebrain@9851: static void FreeLogPointer(); truebrain@9851: truebrain@9851: private: truebrain@9851: /** truebrain@9851: * Internal command to log the message in a common way. truebrain@9851: */ truebrain@9851: static void Log(AILog::AILogType level, const char *message); truebrain@9851: }; truebrain@9851: truebrain@9851: #endif /* AI_LOG_HPP */