projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4879487
)
Sort of working log window.
author
Carl Hetherington
<cth@carlh.net>
Tue, 18 Sep 2012 01:07:59 +0000
(
02:07
+0100)
committer
Carl Hetherington
<cth@carlh.net>
Tue, 18 Sep 2012 01:07:59 +0000
(
02:07
+0100)
src/lib/dcp_video_frame.cc
patch
|
blob
|
history
src/lib/film.cc
patch
|
blob
|
history
src/lib/log.cc
patch
|
blob
|
history
src/lib/log.h
patch
|
blob
|
history
src/lib/server.cc
patch
|
blob
|
history
src/lib/server.h
patch
|
blob
|
history
src/tools/servomatic_cli.cc
patch
|
blob
|
history
src/tools/servomatic_gui.cc
patch
|
blob
|
history
src/wx/config_dialog.cc
patch
|
blob
|
history
diff --git
a/src/lib/dcp_video_frame.cc
b/src/lib/dcp_video_frame.cc
index 91c4415430f1b3f376c08c5e28a4abd3dd8a8057..b128f6fa068d629f603fd92f0c60f3cc7f4384e3 100644
(file)
--- a/
src/lib/dcp_video_frame.cc
+++ b/
src/lib/dcp_video_frame.cc
@@
-277,7
+277,7
@@
DCPVideoFrame::encode_locally ()
{
stringstream s;
{
stringstream s;
- s << "Finished locally-encoded frame " << _frame
<< " length " << cio_tell (_cio)
;
+ s << "Finished locally-encoded frame " << _frame;
_log->log (s.str ());
}
_log->log (s.str ());
}
@@
-342,7
+342,7
@@
DCPVideoFrame::encode_remotely (ServerDescription const * serv)
{
stringstream s;
{
stringstream s;
- s << "Finished remotely-encoded frame " << _frame
<< " length " << e->size()
;
+ s << "Finished remotely-encoded frame " << _frame;
_log->log (s.str ());
}
_log->log (s.str ());
}
diff --git
a/src/lib/film.cc
b/src/lib/film.cc
index f8a3b192da0147b37b3202b68c66457279b1c621..3b74f188824ed207eb7d4a6f5a592584a4f017fe 100644
(file)
--- a/
src/lib/film.cc
+++ b/
src/lib/film.cc
@@
-88,7
+88,7
@@
Film::Film (string d, bool must_exist)
read_metadata ();
read_metadata ();
- _log = new Log (_state.file ("log"));
+ _log = new
File
Log (_state.file ("log"));
}
/** Copy constructor */
}
/** Copy constructor */
diff --git
a/src/lib/log.cc
b/src/lib/log.cc
index accf3694d3775d24609c0149658ab7f76b5a7d87..7f1eea20634f8cba480d8d6884765f7e1be14268 100644
(file)
--- a/
src/lib/log.cc
+++ b/
src/lib/log.cc
@@
-27,10
+27,8
@@
using namespace std;
using namespace std;
-/** @param f Filename to write log to */
-Log::Log (string f)
- : _file (f)
- , _level (VERBOSE)
+Log::Log ()
+ : _level (VERBOSE)
{
}
{
}
@@
-45,13
+43,13
@@
Log::log (string m, Level l)
return;
}
return;
}
- ofstream f (_file.c_str(), fstream::app);
-
time_t t;
time (&t);
string a = ctime (&t);
time_t t;
time (&t);
string a = ctime (&t);
-
- f << a.substr (0, a.length() - 1) << ": " << m << "\n";
+
+ stringstream s;
+ s << a.substr (0, a.length() - 1) << ": " << m;
+ do_log (s.str ());
}
void
}
void
@@
-61,3
+59,18
@@
Log::set_level (Level l)
_level = l;
}
_level = l;
}
+
+/** @param file Filename to write log to */
+FileLog::FileLog (string file)
+ : _file (file)
+{
+
+}
+
+void
+FileLog::do_log (string m)
+{
+ ofstream f (_file.c_str(), fstream::app);
+ f << m << "\n";
+}
+
diff --git
a/src/lib/log.h
b/src/lib/log.h
index d32b368f5a2ed202c3b62658a51c79956bfc8546..2a242e24c96e8f49bfb171d81bac463085ad9f02 100644
(file)
--- a/
src/lib/log.h
+++ b/
src/lib/log.h
@@
-29,15
+29,11
@@
/** @class Log
* @brief A very simple logging class.
/** @class Log
* @brief A very simple logging class.
- *
- * This class simply accepts log messages and writes them to a file.
- * Its single nod to complexity is that it has a mutex to prevent
- * multi-thread logging from clashing.
*/
class Log
{
public:
*/
class Log
{
public:
- Log (
std::string f
);
+ Log ();
enum Level {
STANDARD = 0,
enum Level {
STANDARD = 0,
@@
-48,13
+44,26
@@
public:
void set_level (Level l);
void set_level (Level l);
-pr
ivate:
- /** mutex to pr
event simultaneous writes to the file
*/
+pr
otected:
+ /** mutex to pr
otect the log
*/
boost::mutex _mutex;
boost::mutex _mutex;
- /** filename to write to */
- std::string _file;
+
+private:
+ virtual void do_log (std::string m) = 0;
+
/** level above which to ignore log messages */
Level _level;
};
/** level above which to ignore log messages */
Level _level;
};
+class FileLog : public Log
+{
+public:
+ FileLog (std::string file);
+
+private:
+ void do_log (std::string m);
+ /** filename to write to */
+ std::string _file;
+};
+
#endif
#endif
diff --git
a/src/lib/server.cc
b/src/lib/server.cc
index f4aaa25e128ec193c3c49939bd4419ef1e11997e..9e43601c471218d85ba50e86633ae0a259d6accd 100644
(file)
--- a/
src/lib/server.cc
+++ b/
src/lib/server.cc
@@
-62,8
+62,8
@@
ServerDescription::as_metadata () const
return s.str ();
}
return s.str ();
}
-Server::Server ()
- : _log (
"servomatic.log"
)
+Server::Server (
Log* log
)
+ : _log (
log
)
{
}
{
}
@@
-129,7
+129,7
@@
Server::process (shared_ptr<asio::ip::tcp::socket> socket)
image->hash ("Image for encoding (as received by server)");
#endif
image->hash ("Image for encoding (as received by server)");
#endif
- DCPVideoFrame dcp_video_frame (image, out_size, padding, scaler, frame, frames_per_second, post_process, colour_lut_index, j2k_bandwidth,
&
_log);
+ DCPVideoFrame dcp_video_frame (image, out_size, padding, scaler, frame, frames_per_second, post_process, colour_lut_index, j2k_bandwidth, _log);
shared_ptr<EncodedData> encoded = dcp_video_frame.encode_locally ();
encoded->send (socket);
shared_ptr<EncodedData> encoded = dcp_video_frame.encode_locally ();
encoded->send (socket);
diff --git
a/src/lib/server.h
b/src/lib/server.h
index 8c0f86ebbe5360631df40d16072a4e7871a609c0..58cfe0b3fffa8cc08e5f099a64aedfa201a76d6f 100644
(file)
--- a/
src/lib/server.h
+++ b/
src/lib/server.h
@@
-74,7
+74,7
@@
private:
class Server
{
public:
class Server
{
public:
- Server ();
+ Server (
Log* log
);
void run ();
void run ();
@@
-86,5
+86,5
@@
private:
std::list<boost::shared_ptr<boost::asio::ip::tcp::socket> > _queue;
boost::mutex _worker_mutex;
boost::condition _worker_condition;
std::list<boost::shared_ptr<boost::asio::ip::tcp::socket> > _queue;
boost::mutex _worker_mutex;
boost::condition _worker_condition;
- Log _log;
+ Log
*
_log;
};
};
diff --git
a/src/tools/servomatic_cli.cc
b/src/tools/servomatic_cli.cc
index 1fcd0211787e8d6eb563bb6daca83ef3c5740587..3ad73faf95b2309a836b1faa88386f80ca39703e 100644
(file)
--- a/
src/tools/servomatic_cli.cc
+++ b/
src/tools/servomatic_cli.cc
@@
-44,7
+44,8
@@
int
main ()
{
Scaler::setup_scalers ();
main ()
{
Scaler::setup_scalers ();
- Server server;
+ FileLog log ("servomatic.log");
+ Server server (&log);
server.run ();
return 0;
}
server.run ();
return 0;
}
diff --git
a/src/tools/servomatic_gui.cc
b/src/tools/servomatic_gui.cc
index d89bd91ad67b236c88f1639a8503911f1794dda3..1d95f498a7fb4697baf47e2a85771ea2cb0f0d9f 100644
(file)
--- a/
src/tools/servomatic_gui.cc
+++ b/
src/tools/servomatic_gui.cc
@@
-24,28
+24,65
@@
#include "lib/util.h"
#include "lib/server.h"
#include "lib/util.h"
#include "lib/server.h"
+using namespace std;
using namespace boost;
enum {
ID_status = 1,
using namespace boost;
enum {
ID_status = 1,
- ID_quit
+ ID_quit,
+ ID_timer
};
};
+class MemoryLog : public Log
+{
+public:
+
+ string get () const {
+ boost::mutex::scoped_lock (_mutex);
+ return _log;
+ }
+
+private:
+ void do_log (string m)
+ {
+ _log = m;
+ }
+
+ string _log;
+};
+
+static MemoryLog memory_log;
+
class StatusDialog : public wxDialog
{
public:
StatusDialog ()
class StatusDialog : public wxDialog
{
public:
StatusDialog ()
- : wxDialog (0, wxID_ANY, _("DVD-o-matic encode server"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
+ : wxDialog (0, wxID_ANY, _("DVD-o-matic encode server"), wxDefaultPosition, wxSize (600, 40), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ , _timer (this, ID_timer)
{
{
-
wxFlexGridSizer* table = new wxFlexGridSizer (2
, 6, 6);
-
table->AddGrowableCol (1
, 1);
+
_sizer = new wxFlexGridSizer (1
, 6, 6);
+
_sizer->AddGrowableCol (0
, 1);
- add_label_to_sizer (table, this, "Hello");
+ _text = new wxTextCtrl (this, wxID_ANY);
+ _sizer->Add (_text, 1, wxEXPAND);
- SetSizer (table);
- table->Layout ();
- table->SetSizeHints (this);
+ SetSizer (_sizer);
+ _sizer->Layout ();
+
+ Connect (ID_timer, wxEVT_TIMER, wxTimerEventHandler (StatusDialog::update));
+ _timer.Start (1000);
}
}
+
+private:
+ void update (wxTimerEvent &)
+ {
+ _text->ChangeValue (std_to_wx (memory_log.get ()));
+ _sizer->Layout ();
+ }
+
+ wxFlexGridSizer* _sizer;
+ wxTextCtrl* _text;
+ wxTimer _timer;
};
class TaskBarIcon : public wxTaskBarIcon
};
class TaskBarIcon : public wxTaskBarIcon
@@
-103,7
+140,7
@@
private:
void main_thread ()
{
void main_thread ()
{
- Server server;
+ Server server
(&memory_log)
;
server.run ();
}
server.run ();
}
diff --git
a/src/wx/config_dialog.cc
b/src/wx/config_dialog.cc
index c53eeddf0e4e395d4b40fd60e48f6bce172c8aea..c5d9be41f7964b98e4371f5c9dcc61c6119c2d2c 100644
(file)
--- a/
src/wx/config_dialog.cc
+++ b/
src/wx/config_dialog.cc
@@
-287,6
+287,10
@@
ConfigDialog::remove_server_clicked (wxCommandEvent &)
if (i >= 0) {
_servers->DeleteItem (i);
}
if (i >= 0) {
_servers->DeleteItem (i);
}
+
+ vector<ServerDescription*> o = Config::instance()->servers ();
+ o.erase (o.begin() + i);
+ Config::instance()->set_servers (o);
}
void
}
void