summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-02 16:13:29 +0100
committerCarl Hetherington <cth@carlh.net>2012-10-02 16:13:29 +0100
commit5d48e36440d6b4ebf4c04a413bd340b214ba8c42 (patch)
tree8f4fafd8cdbcadac8efde0cf1ac045ab1301af19 /src/lib
parent9fdcacab9988f4cc5d44a6fab3ab294f5005f468 (diff)
Use String::compose in a few places.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ab_transcode_job.cc4
-rw-r--r--src/lib/check_hashes_job.cc4
-rw-r--r--src/lib/dcp_video_frame.cc12
-rw-r--r--src/lib/examine_content_job.cc4
-rw-r--r--src/lib/film.cc10
-rw-r--r--src/lib/j2k_wav_encoder.cc24
-rw-r--r--src/lib/job.cc4
-rw-r--r--src/lib/make_dcp_job.cc4
-rw-r--r--src/lib/scp_dcp_job.cc36
-rw-r--r--src/lib/server.cc8
-rw-r--r--src/lib/thumbs_job.cc4
-rw-r--r--src/lib/transcode_job.cc9
12 files changed, 32 insertions, 91 deletions
diff --git a/src/lib/ab_transcode_job.cc b/src/lib/ab_transcode_job.cc
index 1a6104251..d94f56d0a 100644
--- a/src/lib/ab_transcode_job.cc
+++ b/src/lib/ab_transcode_job.cc
@@ -46,9 +46,7 @@ ABTranscodeJob::ABTranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const
string
ABTranscodeJob::name () const
{
- stringstream s;
- s << "A/B transcode " << _fs->name;
- return s.str ();
+ return String::compose ("A/B transcode %1", _fs->name);
}
void
diff --git a/src/lib/check_hashes_job.cc b/src/lib/check_hashes_job.cc
index 5a927f752..cf269564a 100644
--- a/src/lib/check_hashes_job.cc
+++ b/src/lib/check_hashes_job.cc
@@ -41,9 +41,7 @@ CheckHashesJob::CheckHashesJob (shared_ptr<const FilmState> s, shared_ptr<const
string
CheckHashesJob::name () const
{
- stringstream s;
- s << "Check hashes of " << _fs->name;
- return s.str ();
+ return String::compose ("Check hashes of %1", _fs->name);
}
void
diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc
index da7133c4b..90826a99f 100644
--- a/src/lib/dcp_video_frame.cc
+++ b/src/lib/dcp_video_frame.cc
@@ -262,11 +262,7 @@ DCPVideoFrame::encode_locally ()
throw EncodeError ("jpeg2000 encoding failed");
}
- {
- stringstream s;
- s << "Finished locally-encoded frame " << _frame;
- _log->log (s.str ());
- }
+ _log->log (String::compose ("Finished locally-encoded frame %1", _frame));
return shared_ptr<EncodedData> (new LocallyEncodedData (_cio->buffer, cio_tell (_cio)));
}
@@ -318,11 +314,7 @@ DCPVideoFrame::encode_remotely (ServerDescription const * serv)
/* now read the rest */
socket.read_definite_and_consume (e->data(), e->size(), 30);
- {
- stringstream s;
- s << "Finished remotely-encoded frame " << _frame;
- _log->log (s.str ());
- }
+ _log->log (String::compose ("Finished remotely-encoded frame %1", _frame));
return e;
}
diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc
index 6927715bd..d77ede2f9 100644
--- a/src/lib/examine_content_job.cc
+++ b/src/lib/examine_content_job.cc
@@ -43,9 +43,7 @@ ExamineContentJob::~ExamineContentJob ()
string
ExamineContentJob::name () const
{
- stringstream s;
- s << "Examine content of " << _fs->name;
- return s.str ();
+ return String::compose ("Examine content of %1", _fs->name);
}
void
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 583a15e19..90c410546 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -483,18 +483,12 @@ Film::make_dcp (bool transcode, int freq)
throw BadSettingError ("name", "cannot contain slashes");
}
- {
- stringstream s;
- s << "DVD-o-matic " << DVDOMATIC_VERSION << " using " << dependency_version_summary ();
- log()->log (s.str ());
- }
+ log()->log (String::compose ("DVD-o-matic %1 using %2", DVDOMATIC_VERSION, dependency_version_summary()));
{
char buffer[128];
gethostname (buffer, sizeof (buffer));
- stringstream s;
- s << "Starting to make a DCP on " << buffer;
- log()->log (s.str ());
+ log()->log (String::compose ("Starting to make DCP on %1", buffer));
}
if (format() == 0) {
diff --git a/src/lib/j2k_wav_encoder.cc b/src/lib/j2k_wav_encoder.cc
index 73aa1bff2..08c796350 100644
--- a/src/lib/j2k_wav_encoder.cc
+++ b/src/lib/j2k_wav_encoder.cc
@@ -169,9 +169,7 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server)
encoded = vf->encode_remotely (server);
if (remote_backoff > 0) {
- stringstream s;
- s << server->host_name() << " was lost, but now she is found; removing backoff";
- _log->log (s.str ());
+ _log->log (String::compose ("%1 was lost, but now she is found; removing backoff", server->host_name ()));
}
/* This job succeeded, so remove any backoff */
@@ -182,9 +180,11 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server)
/* back off more */
remote_backoff += 10;
}
- stringstream s;
- s << "Remote encode of " << vf->frame() << " on " << server->host_name() << " failed (" << e.what() << "); thread sleeping for " << remote_backoff << "s.";
- _log->log (s.str ());
+ _log->log (
+ String::compose (
+ "Remote encode of %1 on %2 failed (%3); thread sleeping for %4s",
+ vf->frame(), server->host_name(), e.what(), remote_backoff)
+ );
}
} else {
@@ -193,9 +193,7 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server)
encoded = vf->encode_locally ();
TIMING ("encoder thread %1 finishes local encode of %2", pthread_self(), vf->frame());
} catch (std::exception& e) {
- stringstream s;
- s << "Local encode failed " << e.what() << ".";
- _log->log (s.str ());
+ _log->log (String::compose ("Local encode failed (%1)", e.what ()));
}
}
@@ -263,17 +261,13 @@ J2KWAVEncoder::process_end ()
*/
for (list<shared_ptr<DCPVideoFrame> >::iterator i = _queue.begin(); i != _queue.end(); ++i) {
- stringstream s;
- s << "Encode left-over frame " << (*i)->frame();
- _log->log (s.str ());
+ _log->log (String::compose ("Encode left-over frame %1", (*i)->frame ()));
try {
shared_ptr<EncodedData> e = (*i)->encode_locally ();
e->write (_opt, (*i)->frame ());
frame_done ((*i)->frame ());
} catch (std::exception& e) {
- stringstream s;
- s << "Local encode failed " << e.what() << ".";
- _log->log (s.str ());
+ _log->log (String::compose ("Local encode failed (%1)", e.what ()));
}
}
diff --git a/src/lib/job.cc b/src/lib/job.cc
index e78a91315..39ce4173a 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -69,9 +69,7 @@ Job::run_wrapper ()
set_progress (1);
set_state (FINISHED_ERROR);
- stringstream s;
- s << e.what() << "(" << filesystem::path (e.filename()).leaf() << ")";
- set_error (s.str ());
+ set_error (String::compose ("%1 (%2)", e.what(), filesystem::path (e.filename()).leaf()));
} catch (std::exception& e) {
diff --git a/src/lib/make_dcp_job.cc b/src/lib/make_dcp_job.cc
index 8d3547cae..ae4bb4fbe 100644
--- a/src/lib/make_dcp_job.cc
+++ b/src/lib/make_dcp_job.cc
@@ -52,9 +52,7 @@ MakeDCPJob::MakeDCPJob (shared_ptr<const FilmState> s, shared_ptr<const Options>
string
MakeDCPJob::name () const
{
- stringstream s;
- s << "Make DCP for " << _fs->name;
- return s.str ();
+ return String::compose ("Make DCP for %1", _fs->name);
}
string
diff --git a/src/lib/scp_dcp_job.cc b/src/lib/scp_dcp_job.cc
index f62d2db8d..dac4a602c 100644
--- a/src/lib/scp_dcp_job.cc
+++ b/src/lib/scp_dcp_job.cc
@@ -78,9 +78,7 @@ public:
{
scp = ssh_scp_new (s, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, Config::instance()->tms_path().c_str ());
if (!scp) {
- stringstream s;
- s << "Could not start SCP session (" << ssh_get_error (s) << ")";
- throw NetworkError (s.str ());
+ throw NetworkError (String::compose ("Could not start SCP session (%1)", ssh_get_error (s)));
}
}
@@ -103,9 +101,7 @@ SCPDCPJob::SCPDCPJob (shared_ptr<const FilmState> s, Log* l)
string
SCPDCPJob::name () const
{
- stringstream s;
- s << "Copy DCP to TMS";
- return s.str ();
+ return "Copy DCP to TMS";
}
void
@@ -124,39 +120,29 @@ SCPDCPJob::run ()
int r = ss.connect ();
if (r != SSH_OK) {
- stringstream s;
- s << "Could not connect to server " << Config::instance()->tms_ip() << " (" << ssh_get_error (ss.session) << ")";
- throw NetworkError (s.str ());
+ throw NetworkError (String::compose ("Could not connect to server %1 (%2)", Config::instance()->tms_ip(), ssh_get_error (ss.session)));
}
int const state = ssh_is_server_known (ss.session);
if (state == SSH_SERVER_ERROR) {
- stringstream s;
- s << "SSH error (" << ssh_get_error (ss.session) << ")";
- throw NetworkError (s.str ());
+ throw NetworkError (String::compose ("SSH error (%1)", ssh_get_error (ss.session)));
}
r = ssh_userauth_password (ss.session, 0, Config::instance()->tms_password().c_str ());
if (r != SSH_AUTH_SUCCESS) {
- stringstream s;
- s << "Failed to authenticate with server (" << ssh_get_error (ss.session) << ")";
- throw NetworkError (s.str ());
+ throw NetworkError (String::compose ("Failed to authenticate with server (%1)", ssh_get_error (ss.session)));
}
SSHSCP sc (ss.session);
r = ssh_scp_init (sc.scp);
if (r != SSH_OK) {
- stringstream s;
- s << "Could not start SCP session (" << ssh_get_error (ss.session) << ")";
- throw NetworkError (s.str ());
+ throw NetworkError (String::compose ("Could not start SCP session (%1)", ssh_get_error (ss.session)));
}
r = ssh_scp_push_directory (sc.scp, _fs->name.c_str(), S_IRWXU);
if (r != SSH_OK) {
- stringstream s;
- s << "Could not create remote directory " << _fs->name << "(" << ssh_get_error (ss.session) << ")";
- throw NetworkError (s.str ());
+ throw NetworkError (String::compose ("Could not create remote directory %1 (%2)", _fs->name, ssh_get_error (ss.session)));
}
string const dcp_dir = _fs->dir (_fs->name);
@@ -186,9 +172,7 @@ SCPDCPJob::run ()
FILE* f = fopen (filesystem::path (*i).string().c_str(), "rb");
if (f == 0) {
- stringstream s;
- s << "Could not open " << *i << " to send";
- throw NetworkError (s.str ());
+ throw NetworkError (String::compose ("Could not open %1 to send", *i));
}
while (to_do > 0) {
@@ -200,9 +184,7 @@ SCPDCPJob::run ()
r = ssh_scp_write (sc.scp, buffer, t);
if (r != SSH_OK) {
- stringstream s;
- s << "Could not write to remote file (" << ssh_get_error (ss.session) << ")";
- throw NetworkError (s.str ());
+ throw NetworkError (String::compose ("Could not write to remote file (%1)", ssh_get_error (ss.session)));
}
to_do -= t;
bytes_transferred += t;
diff --git a/src/lib/server.cc b/src/lib/server.cc
index f8c4425d9..28236e3e0 100644
--- a/src/lib/server.cc
+++ b/src/lib/server.cc
@@ -163,9 +163,7 @@ Server::worker_thread ()
if (frame >= 0) {
struct timeval end;
gettimeofday (&end, 0);
- stringstream s;
- s << "Encoded frame " << frame << " in " << (seconds (end) - seconds (start));
- _log->log (s.str ());
+ _log->log (String::compose ("Encoded frame %1 in %2", frame, seconds (end) - seconds (start)));
}
_worker_condition.notify_all ();
@@ -175,9 +173,7 @@ Server::worker_thread ()
void
Server::run (int num_threads)
{
- stringstream s;
- s << "Server starting with " << num_threads << " threads.";
- _log->log (s.str ());
+ _log->log (String::compose ("Server starting with %1 threads", num_threads));
for (int i = 0; i < num_threads; ++i) {
_worker_threads.push_back (new thread (bind (&Server::worker_thread, this)));
diff --git a/src/lib/thumbs_job.cc b/src/lib/thumbs_job.cc
index 0eb116fd1..f6ed75ff7 100644
--- a/src/lib/thumbs_job.cc
+++ b/src/lib/thumbs_job.cc
@@ -44,9 +44,7 @@ ThumbsJob::ThumbsJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o
string
ThumbsJob::name () const
{
- stringstream s;
- s << "Update thumbs for " << _fs->name;
- return s.str ();
+ return String::compose ("Update thumbs for %1", _fs->name);
}
void
diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc
index 9113593f0..e79be09fe 100644
--- a/src/lib/transcode_job.cc
+++ b/src/lib/transcode_job.cc
@@ -48,9 +48,7 @@ TranscodeJob::TranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const Opti
string
TranscodeJob::name () const
{
- stringstream s;
- s << "Transcode " << _fs->name;
- return s.str ();
+ return String::compose ("Transcode %1", _fs->name);
}
void
@@ -70,12 +68,9 @@ TranscodeJob::run ()
} catch (std::exception& e) {
- stringstream s;
set_progress (1);
set_state (FINISHED_ERROR);
-
- s << "Transcode job failed (" << e.what() << ")";
- _log->log (s.str ());
+ _log->log (String::compose ("Transcode job failed (%1)", e.what()));
throw;
}