mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
move logging into logging folder
- so this special log files are also easy accessable with docker - by the way update default logging channels to use FileChannel and compress and archive rotated logfiles - use logging system from Poco rather than raw FILE for hedera transaction logging
This commit is contained in:
parent
9d3ebb1a75
commit
c13c39e42b
@ -24,6 +24,7 @@
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/AsyncChannel.h"
|
||||
#include "Poco/SimpleFileChannel.h"
|
||||
#include "Poco/FileChannel.h"
|
||||
#include "Poco/ConsoleChannel.h"
|
||||
#include "Poco/SplitterChannel.h"
|
||||
#include "MySQL/Poco/Connector.h"
|
||||
@ -93,8 +94,10 @@ void Gradido_LoginServer::displayHelp()
|
||||
void Gradido_LoginServer::createConsoleFileAsyncLogger(std::string name, std::string filePath)
|
||||
{
|
||||
Poco::AutoPtr<Poco::ConsoleChannel> logConsoleChannel(new Poco::ConsoleChannel);
|
||||
Poco::AutoPtr<Poco::SimpleFileChannel> logFileChannel(new Poco::SimpleFileChannel(filePath));
|
||||
Poco::AutoPtr<Poco::FileChannel> logFileChannel(new Poco::FileChannel(filePath));
|
||||
logFileChannel->setProperty("rotation", "500 K");
|
||||
logFileChannel->setProperty("compress", "true");
|
||||
logFileChannel->setProperty("archive", "timestamp");
|
||||
Poco::AutoPtr<Poco::SplitterChannel> logSplitter(new Poco::SplitterChannel);
|
||||
logSplitter->addChannel(logConsoleChannel);
|
||||
logSplitter->addChannel(logFileChannel);
|
||||
@ -106,6 +109,16 @@ void Gradido_LoginServer::createConsoleFileAsyncLogger(std::string name, std::st
|
||||
log.setLevel("information");
|
||||
}
|
||||
|
||||
void Gradido_LoginServer::createFileLogger(std::string name, std::string filePath)
|
||||
{
|
||||
Poco::AutoPtr<Poco::FileChannel> logFileChannel(new Poco::FileChannel(filePath));
|
||||
logFileChannel->setProperty("rotation", "500 K");
|
||||
logFileChannel->setProperty("archive", "timestamp");
|
||||
Poco::Logger& log = Poco::Logger::get(name);
|
||||
log.setChannel(logFileChannel);
|
||||
log.setLevel("information");
|
||||
}
|
||||
|
||||
int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
{
|
||||
Profiler usedTime;
|
||||
@ -141,6 +154,10 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
// logging for request handling
|
||||
createConsoleFileAsyncLogger("requestLog", log_Path + "requestLog.txt");
|
||||
|
||||
// logging for hedera request for debugging gradido node
|
||||
createFileLogger("transactions_log", log_Path + "transactions_log.txt");
|
||||
createFileLogger("transactions_log_base64", log_Path + "transactions_log_base64.txt");
|
||||
|
||||
// error logging
|
||||
createConsoleFileAsyncLogger("errorLog", log_Path + "errorLog.txt");
|
||||
Poco::Logger& errorLog = Poco::Logger::get("errorLog");
|
||||
|
||||
@ -33,6 +33,7 @@ protected:
|
||||
int main(const std::vector<std::string>& args);
|
||||
|
||||
void createConsoleFileAsyncLogger(std::string name, std::string filePath);
|
||||
void createFileLogger(std::string name, std::string filePath);
|
||||
|
||||
private:
|
||||
bool _helpRequested;
|
||||
|
||||
@ -38,15 +38,21 @@ JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::JSON:
|
||||
try {
|
||||
Profiler phpRequestTime;
|
||||
|
||||
Poco::Net::HTTPSClientSession httpsClientSession(mServerHost, mServerPort);
|
||||
Poco::SharedPtr<Poco::Net::HTTPClientSession> clientSession;
|
||||
if (mServerPort == 443) {
|
||||
clientSession = new Poco::Net::HTTPSClientSession(mServerHost, mServerPort);
|
||||
}
|
||||
else {
|
||||
clientSession = new Poco::Net::HTTPClientSession(mServerHost, mServerPort);
|
||||
}
|
||||
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/JsonRequestHandler");
|
||||
|
||||
request.setChunkedTransferEncoding(true);
|
||||
std::ostream& request_stream = httpsClientSession.sendRequest(request);
|
||||
std::ostream& request_stream = clientSession->sendRequest(request);
|
||||
requestJson.stringify(request_stream);
|
||||
|
||||
Poco::Net::HTTPResponse response;
|
||||
std::istream& response_stream = httpsClientSession.receiveResponse(response);
|
||||
std::istream& response_stream = clientSession->receiveResponse(response);
|
||||
|
||||
// debugging answer
|
||||
|
||||
@ -66,8 +72,13 @@ JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::JSON:
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
addError(new ParamError(functionName, "error parsing request answer", ex.displayText().data()));
|
||||
|
||||
std::string fileName = "response_";
|
||||
std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d%m%yT%H%M%S");
|
||||
std::string log_Path = "/var/log/grd_login/";
|
||||
//#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
log_Path = "./";
|
||||
#endif
|
||||
std::string fileName = log_Path + dateTimeString + "_response_";
|
||||
fileName += methodName;
|
||||
fileName += ".html";
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user