@drwheetos, due to your post I revisited this post because the original problem code I quoted was the same as the “solved” code. This being the case, I looked at my test code again:
/* LOG_TEST_02
Testing v0.6.0 logging
*/
/* Version History
2016-11-28 HR
- Created
*/
class TestClass {
public:
TestClass();
void TestLogging(void);
private:
Logger mLog {"app.testclass"}; // uniform initialisation syntax
};
/*
LOG_LEVEL_ALL : special value that can be used to enable logging of all messages
LOG_LEVEL_TRACE : verbose output for debugging purposes
LOG_LEVEL_INFO : regular information messages
LOG_LEVEL_WARN : warnings and non-critical errors
LOG_LEVEL_ERROR : error messages
LOG_LEVEL_NONE : special value that can be used to disable logging of any messages
*/
SerialLogHandler logHandler(LOG_LEVEL_NONE, { // Logging level for non-application messages
{ "app", LOG_LEVEL_NONE }, // Default logging level for all application messages
{ "app.network", LOG_LEVEL_TRACE }, // Logging level for networking messages
{ "app.setup", LOG_LEVEL_WARN }, // Logging level for setup messages
{ "app.test", LOG_LEVEL_WARN } // Logging level for setup messages
});
// Set up my own logger instance
Logger LogSetup("app.setup");
// Test logging within class
TestClass testClass = TestClass();
void setup() {
delay(2000L);
LogSetup(LOG_LEVEL_INFO, "Setup() completed");
}
void loop() {
// Specify logging level directly
Log(LOG_LEVEL_TRACE, "This is a trace message");
Log(LOG_LEVEL_INFO, "This is an info message");
Log(LOG_LEVEL_WARN, "This is a warn message");
Log(LOG_LEVEL_ERROR, "This is an error message");
delay(1000L);
testClass.TestLogging();
}
TestClass::TestClass(void)
{
}
void TestClass::TestLogging(void)
{
mLog(LOG_LEVEL_TRACE, "TestLogging() - trace message");
mLog(LOG_LEVEL_INFO, "TestLogging() - info message");
mLog(LOG_LEVEL_WARN, "TestLogging() - warn message");
mLog(LOG_LEVEL_ERROR, "TestLogging() - error message");
}
The above gives two compile errors:
/workspace/log_test_02.cpp:45:33: error: use of deleted function 'TestClass::TestClass(TestClass&&)'
^
../wiring/inc/spark_wiring_logging.h:388:5: error: declared here
Logger(const Logger&) = delete;
^