src: improvements to logging
* log messages as they are sent and received * log information about messages by overriding method print() * reduced logging of autocompletion list * removed log location from message and parsing logs, as they are known and make up 90% of logs
This commit is contained in:
@@ -819,7 +819,7 @@ std::vector<SearchMatch> Storage::getAutocompletionMatches(const std::string& qu
|
||||
m_cachedQuery = query;
|
||||
|
||||
std::vector<SearchMatch> matches = SearchIndex::getMatches(m_cachedResults, query);
|
||||
SearchMatch::log(matches, query);
|
||||
LOG_INFO_STREAM(<< matches.size() << " matches for \"" << query << "\"");
|
||||
|
||||
if (matches.size() > 100)
|
||||
{
|
||||
@@ -1803,7 +1803,7 @@ void Storage::buildHierarchyCache()
|
||||
|
||||
void Storage::log(std::string type, std::string str, const ParseLocation& location) const
|
||||
{
|
||||
LOG_INFO_STREAM(
|
||||
LOG_INFO_STREAM_BARE(
|
||||
<< type << ": " << str << " <" << location.filePath.str() << " "
|
||||
<< location.startLineNumber << ":" << location.startColumnNumber << " "
|
||||
<< location.endLineNumber << ":" << location.endColumnNumber << ">"
|
||||
|
||||
@@ -28,9 +28,12 @@ void ConsoleLogger::logError(const LogMessage& message)
|
||||
|
||||
void ConsoleLogger::logMessage(const std::string& type, const LogMessage& message)
|
||||
{
|
||||
std::cout
|
||||
<< message.getTimeString("%H:%M:%S") << " | "
|
||||
<< message.getFileName() << ':' << message.line << ' ' << message.functionName << "() | "
|
||||
<< type << ": " << message.message
|
||||
<< std::endl;
|
||||
std::cout << message.getTimeString("%H:%M:%S") << " | ";
|
||||
|
||||
if (message.filePath.size())
|
||||
{
|
||||
std::cout << message.getFileName() << ':' << message.line << ' ' << message.functionName << "() | ";
|
||||
}
|
||||
|
||||
std::cout << type << ": " << message.message << std::endl;
|
||||
}
|
||||
|
||||
@@ -65,10 +65,13 @@ void FileLogger::logMessage(const std::string& type, const LogMessage& message)
|
||||
{
|
||||
std::ofstream fileStream;
|
||||
fileStream.open(s_filePath + m_fileName, std::ios::app);
|
||||
fileStream
|
||||
<< message.getTimeString("%H:%M:%S") << " | "
|
||||
<< message.getFileName() << ':' << message.line << ' ' << message.functionName << "() | "
|
||||
<< type << ": " << message.message
|
||||
<< std::endl;
|
||||
fileStream << message.getTimeString("%H:%M:%S") << " | ";
|
||||
|
||||
if (message.filePath.size())
|
||||
{
|
||||
fileStream << message.getFileName() << ':' << message.line << ' ' << message.functionName << "() | ";
|
||||
}
|
||||
|
||||
fileStream << type << ": " << message.message << std::endl;
|
||||
fileStream.close();
|
||||
}
|
||||
|
||||
@@ -56,4 +56,13 @@
|
||||
} \
|
||||
while(0) \
|
||||
|
||||
#define LOG_INFO_STREAM_BARE(__s__) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream __ss__; \
|
||||
__ss__ __s__; \
|
||||
LogManager::getInstance()->logInfo(__ss__.str(), "", "", 0); \
|
||||
} \
|
||||
while(0) \
|
||||
|
||||
#endif // LOGGING_H
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
|
||||
template<typename MessageType>
|
||||
class Message: public MessageBase
|
||||
class Message
|
||||
: public MessageBase
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -32,6 +33,10 @@ public:
|
||||
std::shared_ptr<MessageBase> message = std::make_shared<MessageType>(*dynamic_cast<MessageType*>(this));
|
||||
MessageQueue::getInstance()->processMessage(message, true);
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_H
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#ifndef MESSAGE_BASE_H
|
||||
#define MESSAGE_BASE_H
|
||||
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
class MessageBase
|
||||
{
|
||||
@@ -58,6 +59,16 @@ public:
|
||||
return m_keepContent;
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const = 0;
|
||||
|
||||
std::string str() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << getType() << " ";
|
||||
print(ss);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
UndoType undoRedoType;
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/MessageBase.h"
|
||||
#include "utility/messaging/MessageListenerBase.h"
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
|
||||
template<typename MessageType>
|
||||
class MessageListener: public MessageListenerBase
|
||||
class MessageListener
|
||||
: public MessageListenerBase
|
||||
{
|
||||
public:
|
||||
MessageListener()
|
||||
@@ -23,6 +25,7 @@ private:
|
||||
|
||||
virtual void doHandleMessageBase(MessageBase* message)
|
||||
{
|
||||
LOG_INFO_STREAM_BARE(<< "handle " << message->str());
|
||||
handleMessage(dynamic_cast<MessageType*>(message));
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ void MessageQueue::pushMessage(std::shared_ptr<MessageBase> message)
|
||||
|
||||
void MessageQueue::processMessage(std::shared_ptr<MessageBase> message, bool asNextTask)
|
||||
{
|
||||
LOG_INFO_STREAM_BARE(<< "send " << message->str());
|
||||
|
||||
if (m_sendMessagesAsTasks && message->sendAsTask())
|
||||
{
|
||||
sendMessageAsTask(message, asNextTask);
|
||||
|
||||
@@ -35,6 +35,11 @@ public:
|
||||
return Edge::getTypeString(type) + ":" + fromNameHierarchy.getFullName() + "->" + toNameHierarchy.getFullName();
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << tokenId << " - " << getFullName();
|
||||
}
|
||||
|
||||
const Id tokenId;
|
||||
const Edge::EdgeType type;
|
||||
const NameHierarchy fromNameHierarchy;
|
||||
|
||||
@@ -17,6 +17,11 @@ public:
|
||||
return "MessageActivateFile";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << filePath.str();
|
||||
}
|
||||
|
||||
const FilePath filePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -37,6 +37,14 @@ public:
|
||||
return "MessageActivateNodes";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
for (const ActiveNode& node : nodes)
|
||||
{
|
||||
os << node.nodeId << " ";
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ActiveNode> nodes;
|
||||
|
||||
bool isFromSystem;
|
||||
|
||||
@@ -18,6 +18,14 @@ public:
|
||||
return "MessageActivateTokenLocations";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
for (const Id& id : locationIds)
|
||||
{
|
||||
os << id << " ";
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Id> locationIds;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,14 @@ public:
|
||||
return "MessageActivateTokens";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
for (const Id& id : tokenIds)
|
||||
{
|
||||
os << id << " ";
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Id> tokenIds;
|
||||
|
||||
bool isEdge;
|
||||
|
||||
@@ -16,6 +16,18 @@ public:
|
||||
return "MessageAutoRefreshChanged";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
os << "enabled";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "disabled";
|
||||
}
|
||||
}
|
||||
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,6 +41,11 @@ public:
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << getStatusStr();
|
||||
}
|
||||
|
||||
size_t fileCount;
|
||||
size_t totalFileCount;
|
||||
float parseTime;
|
||||
|
||||
@@ -20,6 +20,14 @@ public:
|
||||
return "MessageFocusIn";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
for (const Id& id : tokenIds)
|
||||
{
|
||||
os << id << " ";
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Id> tokenIds;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,15 @@ public:
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageHoverLeave";
|
||||
return "MessageFocusOut";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
for (const Id& id : tokenIds)
|
||||
{
|
||||
os << id << " ";
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Id> tokenIds;
|
||||
|
||||
@@ -18,6 +18,11 @@ public:
|
||||
return "MessageGraphNodeBundleSplit";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << bundleId;
|
||||
}
|
||||
|
||||
Id bundleId;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,19 @@ public:
|
||||
return "MessageGraphNodeExpand";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << tokenId << " ";
|
||||
if (expand)
|
||||
{
|
||||
os << "expand";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "collapse";
|
||||
}
|
||||
}
|
||||
|
||||
const Id tokenId;
|
||||
const bool expand;
|
||||
};
|
||||
|
||||
@@ -20,6 +20,11 @@ public:
|
||||
return "MessageGraphNodeMove";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << tokenId << " " << delta.toString();
|
||||
}
|
||||
|
||||
const Id tokenId;
|
||||
const Vec2i delta;
|
||||
};
|
||||
|
||||
@@ -16,6 +16,11 @@ public:
|
||||
return "MessageLoadProject";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << projectSettingsFilePath;
|
||||
}
|
||||
|
||||
const std::string projectSettingsFilePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ public:
|
||||
return "MessageMoveIDECursor";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << FilePosition << ":" << Row << ":" << Column;
|
||||
}
|
||||
|
||||
const std::string FilePosition;
|
||||
const unsigned int Row;
|
||||
const unsigned int Column;
|
||||
|
||||
@@ -29,6 +29,18 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
if (uiOnly)
|
||||
{
|
||||
os << "ui ";
|
||||
}
|
||||
if (all)
|
||||
{
|
||||
os << "all";
|
||||
}
|
||||
}
|
||||
|
||||
bool uiOnly;
|
||||
bool all;
|
||||
};
|
||||
|
||||
@@ -16,6 +16,11 @@ public:
|
||||
return "MessageSaveProject";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << projectSettingsFilePath;
|
||||
}
|
||||
|
||||
const std::string projectSettingsFilePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,11 @@ public:
|
||||
return m_matches;
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << getMatchesAsString();
|
||||
}
|
||||
|
||||
private:
|
||||
const std::vector<SearchMatch> m_matches;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,11 @@ public:
|
||||
return "MessageSearchAutocomplete";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << query;
|
||||
}
|
||||
|
||||
const std::string query;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@ public:
|
||||
return "MessageShowFile";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << filePath.str();
|
||||
}
|
||||
|
||||
const FilePath filePath;
|
||||
const bool showErrors;
|
||||
};
|
||||
|
||||
@@ -18,6 +18,11 @@ public:
|
||||
return "MessageShowScope";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << scopeLocationId;
|
||||
}
|
||||
|
||||
const Id scopeLocationId;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class TokenLocationFile;
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
|
||||
class MessageShowSnippets
|
||||
: public Message<MessageShowSnippets>
|
||||
@@ -20,6 +20,11 @@ public:
|
||||
return "MessageShowSnippets";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << locationFile->getFilePath().str();
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenLocationFile> locationFile;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,21 @@ public:
|
||||
return "MessageStatus";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << status;
|
||||
|
||||
if (isError)
|
||||
{
|
||||
os << " - error";
|
||||
}
|
||||
|
||||
if (showLoader)
|
||||
{
|
||||
os << " - loading";
|
||||
}
|
||||
}
|
||||
|
||||
const std::string status;
|
||||
const bool isError;
|
||||
const bool showLoader;
|
||||
|
||||
@@ -17,6 +17,11 @@ public:
|
||||
return "MessageSwitchColorScheme";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << colorSchemeFilePath;
|
||||
}
|
||||
|
||||
const std::string colorSchemeFilePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,18 @@ public:
|
||||
return "MessageZoom";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
if (zoomIn)
|
||||
{
|
||||
os << "in";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "out";
|
||||
}
|
||||
}
|
||||
|
||||
const bool zoomIn;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user