From e1d54b6b3a95b37e2e8e807387a725fe5d202c2c Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 16 Dec 2013 14:38:14 +0000 Subject: context logging --- rotord/src/graph.cpp | 6 ++++-- rotord/src/graph.h | 6 +++++- rotord/src/rendercontext.cpp | 2 +- rotord/src/rendercontext.h | 48 ++++++++++++++++++++++++++++++++++++++++++++ rotord/src/rotor.h | 11 ++++++---- 5 files changed, 65 insertions(+), 8 deletions(-) (limited to 'rotord') diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 96c313f..521a18e 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -139,7 +139,7 @@ bool Graph::video_render(const string &output_filename,const double framerate,in bool usingaudio=audioloader.open(audio_filename); - Logger& logger = Logger::get("Rotor"); + Logger& logger = Logger::get(Log_name); logger.information("Video_output rendering "+output_filename+": "+toString(duration)+" seconds at "+toString(framerate)+" fps, audio frame size: "+toString(exporter.get_audio_framesize())); //25fps video and 43.06640625fps audio? hmm //how to get the timecodes correct for the interleaved files @@ -333,6 +333,7 @@ bool Graph::parseJson(string &data,string &media_path){ map settings; vector attrs; settings["type"]=jnodes[i]["type"].asString(); + settings["Log_name"]=Log_name; //attributes settings["media_path"]=media_path; for (uint32_t m=0;m processors){ if (filename.size()==0) return false; - Logger& logger = Logger::get("Rotor"); + Logger& logger = Logger::get(Log_name); logger.information("Analysing "+filename+" seed:"+toString(analysis_seed)); diff --git a/rotord/src/graph.h b/rotord/src/graph.h index 153bc5a..dc24c84 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -25,7 +25,7 @@ copy nodes ` namespace Rotor { class Graph{ public: - Graph(){duration=20.0;loaded = false;audio_loaded=false;bitRate=0;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();use_fragmentation=false;analysis_seed=0;}; + Graph(){duration=20.0;loaded = false;audio_loaded=false;bitRate=0;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();use_fragmentation=false;analysis_seed=0;Log_name="";}; Graph(const string& _uid,const string& _desc){ Graph(); init(_uid,_desc); @@ -84,6 +84,9 @@ namespace Rotor { bool cancelled; double progress; int bitRate; + void set_log_name(string _Log_name){ + Log_name=_Log_name; + } //Poco::Mutex mutex; //lock for access from parent thread @@ -92,6 +95,7 @@ namespace Rotor { int outW,outH; bool use_fragmentation; int analysis_seed; + string Log_name; }; class Thumbnailer{ diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index 0015488..6d76fbc 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -86,7 +86,7 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H s+=" "; } - Logger& logger = Logger::get("Rotor"); + Logger& logger = Logger::get(Log_name); status=HTTPResponse::HTTP_BAD_REQUEST; //error by default if (command.commands[1]=="resolution") { if (command.method=="PUT") { diff --git a/rotord/src/rendercontext.h b/rotord/src/rendercontext.h index 380e197..202bc19 100644 --- a/rotord/src/rendercontext.h +++ b/rotord/src/rendercontext.h @@ -7,6 +7,28 @@ #include "rotor.h" #include "graph.h" +#include "Poco/URI.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; + /*------------------------ Render context packages the management of a rotor graph as a web service @@ -72,6 +94,30 @@ namespace Rotor { else cerr<<"Rotor: settings.xml not found, using defaults"< splitterChannel(new SplitterChannel()); + AutoPtr consoleChannel(new ConsoleChannel()); + AutoPtr fileChannel(new FileChannel("Rotord_session_"+name+".log")); + //AutoPtr rotatedFileChannel(new FileChannel("Rotord_R.log")); + + //rotatedFileChannel->setProperty("rotation", "100"); + //rotatedFileChannel->setProperty("archive", "timestamp"); + + splitterChannel->addChannel(consoleChannel); + splitterChannel->addChannel(fileChannel); + //splitterChannel->addChannel(rotatedFileChannel); + + AutoPtr formatter(new PatternFormatter("%d-%m-%Y %H:%M:%S %s: %t")); + AutoPtr formattingChannel(new FormattingChannel(formatter, splitterChannel)); + + Log_name="Context "+name; + graph.set_log_name(Log_name); + + Logger& sLog = Logger::create(Log_name, formattingChannel, Message::PRIO_TRACE); + + + Logger& logger = Logger::get(Log_name); + logger.information("started thread"); }; ~Render_context(){}; void runTask(); @@ -108,6 +154,8 @@ namespace Rotor { std::string graph_filename; std::string graph_body; + std::string Log_name; + Poco::Mutex mutex; //lock for access from parent thread Audio_thumbnailer *audio_thumb; diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 174a622..f256f66 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -380,6 +380,7 @@ namespace Rotor { string NODEID; string title; string UItype; + string Log_name; bool duplicate_inputs; string find_setting(map &settings,string key,string def=""){ if (settings.find(key)!=settings.end()) return settings[key]; else return def;}; double find_setting(map &settings,string key,double def){ if (settings.find(key)!=settings.end()) return toFloat(settings[key]); else return def;}; @@ -389,6 +390,7 @@ namespace Rotor { type=find_setting(settings,"type"); ID=find_setting(settings,"ID"); title=find_setting(settings,"title"); + Log_name=find_setting(settings,"Log_name"); for (auto a: attributes){ if (find_setting(settings,a.first,"")!="") { attributes[a.first]->init(find_setting(settings,a.first,"")); @@ -718,6 +720,7 @@ namespace Rotor { } return in1; } + //log this return nullptr; } //cut mode @@ -755,7 +758,7 @@ namespace Rotor { isLoaded=false; }; bool load(const string &filename){ - Poco::Logger& logger = Poco::Logger::get("Rotor"); + Poco::Logger& logger = Poco::Logger::get(Log_name); isLoaded=player.open(filename); if (isLoaded){ logger.information("libav::decoder loaded "+filename+": "\ @@ -800,7 +803,7 @@ namespace Rotor { else { if (((int)wanted)!=Base_video::lastframe){ if (!player.fetch_frame(frame.w,frame.h,((int)wanted))) { //seek fail - Poco::Logger& logger = Poco::Logger::get("Rotor"); + Poco::Logger& logger = Poco::Logger::get(Log_name); logger.error("Video_loader failed to seek frame "+toString(wanted)+" of "+attributes["filename"]->value); if (image.w>0) return ℑ //just return the previous frame if possible @@ -908,7 +911,7 @@ namespace Rotor { ~Video_bank(){}; bool load(int v){ if (players[v].loaded) return true; - Poco::Logger& logger = Poco::Logger::get("Rotor"); + Poco::Logger& logger = Poco::Logger::get(Log_name); players[v]=libav::video_decoder(); string filename=media_path+attributes["filenames"]->vals[v]; isLoaded=players[v].open(filename); @@ -955,7 +958,7 @@ namespace Rotor { else { if (((int)wanted)!=Base_video::lastframe){ if (!players[clip_loaded].fetch_frame(frame.w,frame.h,((int)wanted))) { //seek fail - Poco::Logger& logger = Poco::Logger::get("Rotor"); + Poco::Logger& logger = Poco::Logger::get(Log_name); logger.error("Video_loader failed to seek frame "+toString(wanted)+" of "+attributes["filename"]->value); if (image.w>0) return ℑ //just return the previous frame if possible -- cgit v1.2.3