| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #pragma once
- #include "BsPrerequisitesUtil.h"
- namespace BansheeEngine
- {
- /** @addtogroup Debug
- * @{
- */
- /** A single log entry, containing a message and a channel the message was recorded on. */
- class BS_UTILITY_EXPORT LogEntry
- {
- public:
- LogEntry() { }
- LogEntry(const String& msg, UINT32 channel);
- /** Channel the message was recorded on. */
- UINT32 getChannel() const { return mChannel; }
- /** Text of the message. */
- const String& getMessage() const { return mMsg; }
- private:
- String mMsg;
- UINT32 mChannel;
- };
- /**
- * Used for logging messages. Can categorize messages according to channels, save the log to a file
- * and send out callbacks when a new message is added.
- *
- * @note Thread safe.
- */
- class BS_UTILITY_EXPORT Log
- {
- public:
- Log();
- ~Log();
- /**
- * Logs a new message.
- *
- * @param[in] message The message describing the log entry.
- * @param[in] channel Channel in which to store the log entry.
- */
- void logMsg(const String& message, UINT32 channel);
- /** Removes all log entries. */
- void clear();
- /** Removes all log entries in a specific channel. */
- void clear(UINT32 channel);
- /** Returns all existing log entries. */
- Vector<LogEntry> getEntries() const;
- /**
- * Returns the latest unread entry from the log queue, and removes the entry from the unread entries list.
- *
- * @param[out] entry Entry that was retrieved, or undefined if no entries exist.
- * @return True if an unread entry was retrieved, false otherwise.
- */
- bool getUnreadEntry(LogEntry& entry);
- /**
- * Returns the last available log entry.
- *
- * @param[out] entry Entry that was retrieved, or undefined if no entries exist.
- * @return True if an entry was retrieved, false otherwise.
- */
- bool getLastEntry(LogEntry& entry);
- /**
- * Returns a hash value that is modified whenever entries in the log change. This can be used for
- * checking for changes by external systems.
- */
- UINT64 getHash() const { return mHash; }
- private:
- friend class Debug;
- /** Returns all log entries, including those marked as unread. */
- Vector<LogEntry> getAllEntries() const;
- Vector<LogEntry> mEntries;
- Queue<LogEntry> mUnreadEntries;
- UINT64 mHash;
- BS_RECURSIVE_MUTEX(mMutex);
- };
- /** @} */
- }
|