Skip to content
Snippets Groups Projects
Commit f92e7d30 authored by Oz Linden's avatar Oz Linden
Browse files

Add logging during tests (debug level, to test-specific files)

parent fb1fa843
No related branches found
No related tags found
No related merge requests found
...@@ -534,7 +534,7 @@ namespace ...@@ -534,7 +534,7 @@ namespace
} }
void commonInit(const std::string& dir) void commonInit(const std::string& dir, bool log_to_stderr = true)
{ {
LLError::Settings::reset(); LLError::Settings::reset();
...@@ -542,7 +542,8 @@ namespace ...@@ -542,7 +542,8 @@ namespace
LLError::setFatalFunction(LLError::crashAndLoop); LLError::setFatalFunction(LLError::crashAndLoop);
LLError::setTimeFunction(LLError::utcTime); LLError::setTimeFunction(LLError::utcTime);
if (shouldLogToStderr()) // log_to_stderr is only false in the unit and integration tests to keep builds quieter
if (log_to_stderr && shouldLogToStderr())
{ {
LLError::addRecorder(new RecordToStderr(stderrLogWantsTime())); LLError::addRecorder(new RecordToStderr(stderrLogWantsTime()));
} }
...@@ -580,9 +581,9 @@ namespace LLError ...@@ -580,9 +581,9 @@ namespace LLError
#endif #endif
} }
void initForApplication(const std::string& dir) void initForApplication(const std::string& dir, bool log_to_stderr)
{ {
commonInit(dir); commonInit(dir, log_to_stderr);
} }
void setPrintLocation(bool print) void setPrintLocation(bool print)
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "stdtypes.h" #include "stdtypes.h"
/* Error Logging Facility /** Error Logging Facility
Information for most users: Information for most users:
...@@ -100,7 +100,6 @@ ...@@ -100,7 +100,6 @@
even release. Which means you can use them to help debug even when deployed even release. Which means you can use them to help debug even when deployed
to a real grid. to a real grid.
*/ */
namespace LLError namespace LLError
{ {
enum ELevel enum ELevel
......
...@@ -62,7 +62,7 @@ namespace LLError ...@@ -62,7 +62,7 @@ namespace LLError
// logs to stderr, syslog, and windows debug log // logs to stderr, syslog, and windows debug log
// the identity string is used for in the syslog // the identity string is used for in the syslog
LL_COMMON_API void initForApplication(const std::string& dir); LL_COMMON_API void initForApplication(const std::string& dir, bool log_to_stderr = true);
// resets all logging settings to defaults needed by applicaitons // resets all logging settings to defaults needed by applicaitons
// logs to stderr and windows debug log // logs to stderr and windows debug log
// sets up log configuration from the file logcontrol.xml in dir // sets up log configuration from the file logcontrol.xml in dir
......
...@@ -113,13 +113,16 @@ class LLTestCallback : public tut::callback ...@@ -113,13 +113,16 @@ class LLTestCallback : public tut::callback
virtual void run_started() virtual void run_started()
{ {
//std::cout << "run_started" << std::endl; //std::cout << "run_started" << std::endl;
LL_INFOS("TestRunner")<<"Test Started"<< LL_ENDL;
} }
virtual void group_started(const std::string& name) { virtual void group_started(const std::string& name) {
LL_INFOS("TestRunner")<<"Unit test group_started name=" << name << LL_ENDL;
*mStream << "Unit test group_started name=" << name << std::endl; *mStream << "Unit test group_started name=" << name << std::endl;
} }
virtual void group_completed(const std::string& name) { virtual void group_completed(const std::string& name) {
LL_INFOS("TestRunner")<<"Unit test group_completed name=" << name << LL_ENDL;
*mStream << "Unit test group_completed name=" << name << std::endl; *mStream << "Unit test group_completed name=" << name << std::endl;
} }
...@@ -167,9 +170,11 @@ class LLTestCallback : public tut::callback ...@@ -167,9 +170,11 @@ class LLTestCallback : public tut::callback
if(!tr.message.empty()) if(!tr.message.empty())
{ {
*mStream << ": '" << tr.message << "'"; *mStream << ": '" << tr.message << "'";
LL_WARNS("TestRunner") << "not ok : "<<tr.message << LL_ENDL;
} }
*mStream << std::endl; *mStream << std::endl;
} }
LL_INFOS("TestRunner")<<out.str()<<LL_ENDL;
} }
virtual int getFailedTests() const { return mFailedTests; } virtual int getFailedTests() const { return mFailedTests; }
...@@ -389,11 +394,14 @@ int main(int argc, char **argv) ...@@ -389,11 +394,14 @@ int main(int argc, char **argv)
#ifndef LL_WINDOWS #ifndef LL_WINDOWS
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
#endif #endif
LLError::initForApplication("."); LLError::initForApplication(".", false /* do not log to stderr */);
LLError::setFatalFunction(wouldHaveCrashed); LLError::setFatalFunction(wouldHaveCrashed);
LLError::setDefaultLevel(LLError::LEVEL_ERROR); LLError::setDefaultLevel(LLError::LEVEL_DEBUG);
//< *TODO: should come from error config file. Note that we LLError::setPrintLocation(true);
// have a command line option that sets this to debug. std::string test_app_name(argv[0]);
std::string test_log = test_app_name + ".log";
LLFile::remove(test_log);
LLError::logToFile(test_log);
#ifdef CTYPE_WORKAROUND #ifdef CTYPE_WORKAROUND
ctype_workaround(); ctype_workaround();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment