From efebf20348daca798c22cbac770d47e9151f941f Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 23 Jan 2014 14:03:07 +0000 Subject: NT logging structure --- NT/src/graph.cpp | 5 +++-- NT/src/rendercontext.h | 28 +++++++++++++++++++++++++--- NT/src/rotor.cpp | 7 ++++--- NT/src/rotor.h | 22 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 8 deletions(-) (limited to 'NT') diff --git a/NT/src/graph.cpp b/NT/src/graph.cpp index ef638cc..e671238 100644 --- a/NT/src/graph.cpp +++ b/NT/src/graph.cpp @@ -4,16 +4,17 @@ using namespace Rotor; using namespace std; bool Graph::check_audio(string audio,string path){ + Logger& logger = Logger::get(id); if (audio!="") { audio_filename=path+audio; Poco::File f=Poco::File(audio_filename); if (f.exists()) { //here we should check the audio is actually valid audio_loaded=true; - cerr<<"Rotor: loading "< splitterChannel(new SplitterChannel()); + AutoPtr consoleChannel(new ConsoleChannel()); + AutoPtr fileChannel(new FileChannel("Rotord_"+id+".log")); + splitterChannel->addChannel(consoleChannel); + splitterChannel->addChannel(fileChannel); + AutoPtr formatter(new PatternFormatter("%d-%m-%Y %H:%M:%S %s: %t")); + AutoPtr formattingChannel(new FormattingChannel(formatter, splitterChannel)); + Logger& logger = Logger::create(id, formattingChannel, Message::PRIO_TRACE); + logger.information("started thread"); + } + ~Render_context(){ + Logger& logger = Logger::get(id); + cancel(); + logger.information("stopped thread"); + } + void runTask() { + Logger& logger = Logger::get(id); + while (!isCancelled()) { + sleep(100); + } } - private: Graph graph; + private: + std::string id; }; }; diff --git a/NT/src/rotor.cpp b/NT/src/rotor.cpp index bf0c26a..f600c7f 100644 --- a/NT/src/rotor.cpp +++ b/NT/src/rotor.cpp @@ -4,6 +4,7 @@ #include "factory.h" #include "nodes.h" #include "graph.h" +#include "rendercontext.h" using namespace std; using namespace Rotor; @@ -82,8 +83,8 @@ int main(){ delete m; delete p; */ - Rotor::Graph g; - cerr<<(g.load_file("testgraph.json","./")?"loaded ":"could not load ")<<"testgraph.json"< #include +#include "Poco/Logger.h" +#include "Poco/Channel.h" +#include "Poco/SplitterChannel.h" +#include "Poco/ConsoleChannel.h" +#include "Poco/FormattingChannel.h" +#include "Poco/FileChannel.h" +#include "Poco/Message.h" +#include "Poco/Formatter.h" +#include "Poco/PatternFormatter.h" +#include "Poco/AutoPtr.h" + +using Poco::Logger; +using Poco::Channel; +using Poco::SplitterChannel; +using Poco::ConsoleChannel; +using Poco::FormattingChannel; +using Poco::Formatter; +using Poco::PatternFormatter; +using Poco::FileChannel; +using Poco::Message; +using Poco::AutoPtr; + template struct TypeName { -- cgit v1.2.3