--- /dev/null
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "file_log.h"
+#include "cross.h"
+#include <cstdio>
+
+using std::cout;
+using std::string;
+using std::max;
+
+/** @param file Filename to write log to */
+FileLog::FileLog (boost::filesystem::path file)
+ : _file (file)
+{
+
+}
+
+void
+FileLog::do_log (string m)
+{
+ FILE* f = fopen_boost (_file, "a");
+ if (!f) {
+ cout << "(could not log to " << _file.string() << "): " << m << "\n";
+ return;
+ }
+
+ fprintf (f, "%s\n", m.c_str ());
+ fclose (f);
+}
+
+string
+FileLog::head_and_tail (int amount) const
+{
+ boost::mutex::scoped_lock lm (_mutex);
+
+ uintmax_t head_amount = amount;
+ uintmax_t tail_amount = amount;
+ uintmax_t size = boost::filesystem::file_size (_file);
+
+ if (size < (head_amount + tail_amount)) {
+ head_amount = size;
+ tail_amount = 0;
+ }
+
+ FILE* f = fopen_boost (_file, "r");
+ if (!f) {
+ return "";
+ }
+
+ string out;
+
+ char* buffer = new char[max(head_amount, tail_amount) + 1];
+
+ int N = fread (buffer, 1, head_amount, f);
+ buffer[N] = '\0';
+ out += string (buffer);
+
+ if (tail_amount > 0) {
+ out += "\n .\n .\n .\n";
+
+ fseek (f, - tail_amount - 1, SEEK_END);
+
+ N = fread (buffer, 1, tail_amount, f);
+ buffer[N] = '\0';
+ out += string (buffer) + "\n";
+ }
+
+ delete[] buffer;
+ fclose (f);
+
+ return out;
+}
--- /dev/null
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "log.h"
+
+class FileLog : public Log
+{
+public:
+ FileLog (boost::filesystem::path file);
+
+ std::string head_and_tail (int amount = 1024) const;
+
+private:
+ void do_log (std::string m);
+ /** filename to write to */
+ boost::filesystem::path _file;
+};
#include "job_manager.h"
#include "transcode_job.h"
#include "upload_job.h"
-#include "log.h"
+#include "null_log.h"
+#include "file_log.h"
#include "exceptions.h"
#include "examine_content_job.h"
#include "config.h"
boost::mutex::scoped_lock lm (_mutex);
_types = t;
}
-
-/** @param file Filename to write log to */
-FileLog::FileLog (boost::filesystem::path file)
- : _file (file)
-{
-
-}
-
-void
-FileLog::do_log (string m)
-{
- FILE* f = fopen_boost (_file, "a");
- if (!f) {
- cout << "(could not log to " << _file.string() << "): " << m << "\n";
- return;
- }
-
- fprintf (f, "%s\n", m.c_str ());
- fclose (f);
-}
-
-string
-FileLog::head_and_tail (int amount) const
-{
- boost::mutex::scoped_lock lm (_mutex);
-
- uintmax_t head_amount = amount;
- uintmax_t tail_amount = amount;
- uintmax_t size = boost::filesystem::file_size (_file);
-
- if (size < (head_amount + tail_amount)) {
- head_amount = size;
- tail_amount = 0;
- }
-
- FILE* f = fopen_boost (_file, "r");
- if (!f) {
- return "";
- }
-
- string out;
-
- char* buffer = new char[max(head_amount, tail_amount) + 1];
-
- int N = fread (buffer, 1, head_amount, f);
- buffer[N] = '\0';
- out += string (buffer);
-
- if (tail_amount > 0) {
- out += "\n .\n .\n .\n";
-
- fseek (f, - tail_amount - 1, SEEK_END);
-
- N = fread (buffer, 1, tail_amount, f);
- buffer[N] = '\0';
- out += string (buffer) + "\n";
- }
-
- delete[] buffer;
- fclose (f);
-
- return out;
-}
boost::signals2::scoped_connection _config_connection;
};
-class FileLog : public Log
-{
-public:
- FileLog (boost::filesystem::path file);
-
- std::string head_and_tail (int amount = 1024) const;
-
-private:
- void do_log (std::string m);
- /** filename to write to */
- boost::filesystem::path _file;
-};
-
-class NullLog : public Log
-{
-public:
- std::string head_and_tail (int) const {
- return "";
- }
-
-private:
- void do_log (std::string) {}
-};
-
#endif
--- /dev/null
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "log.h"
+
+class NullLog : public Log
+{
+public:
+ std::string head_and_tail (int) const {
+ return "";
+ }
+
+private:
+ void do_log (std::string) {}
+};
examine_content_job.cc
exceptions.cc
file_group.cc
+ file_log.cc
filter_graph.cc
ffmpeg.cc
ffmpeg_audio_stream.cc
*/
-#include "lib/server.h"
-#include <iostream>
-#include <stdexcept>
-#include <cstring>
-#include <vector>
-#include <unistd.h>
-#include <errno.h>
-#include <getopt.h>
-#include <boost/array.hpp>
-#include <boost/asio.hpp>
-#include <boost/algorithm/string.hpp>
-#include <boost/thread.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/condition.hpp>
#include "lib/config.h"
#include "lib/dcp_video.h"
#include "lib/exceptions.h"
#include "lib/util.h"
#include "lib/config.h"
#include "lib/image.h"
-#include "lib/log.h"
+#include "lib/file_log.h"
+#include "lib/null_log.h"
#include "lib/version.h"
+#include "lib/server.h"
+#include <boost/array.hpp>
+#include <boost/asio.hpp>
+#include <boost/algorithm/string.hpp>
+#include <boost/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <unistd.h>
+#include <errno.h>
+#include <getopt.h>
+#include <iostream>
+#include <stdexcept>
+#include <cstring>
+#include <vector>
using std::cerr;
using std::string;
#include "lib/dcp_video.h"
#include "lib/decoder.h"
#include "lib/exceptions.h"
-#include "lib/log.h"
+#include "lib/file_log.h"
#include "lib/video_decoder.h"
#include "lib/player.h"
#include "lib/player_video.h"
#include "lib/raw_image_proxy.h"
#include "lib/data.h"
#include "lib/server_description.h"
-#include "lib/log.h"
+#include "lib/file_log.h"
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
delete server;
}
-
* it probably should.
*/
-#include <vector>
-#include <boost/test/unit_test.hpp>
-#include <boost/filesystem.hpp>
#include "lib/ffmpeg_content.h"
#include "lib/ffmpeg_decoder.h"
-#include "lib/log.h"
+#include "lib/null_log.h"
#include "lib/film.h"
#include "test.h"
+#include <boost/test/unit_test.hpp>
+#include <boost/filesystem.hpp>
+#include <vector>
using std::cerr;
using std::vector;
test ("prophet_clip.mkv", frames);
}
-
* (dropped frames being checked by assert() in VideoDecoder). Also that the decoder picks up frame rates correctly.
*/
-#include <boost/test/unit_test.hpp>
-#include <boost/filesystem.hpp>
#include "lib/ffmpeg_content.h"
#include "lib/ffmpeg_decoder.h"
-#include "lib/log.h"
+#include "lib/null_log.h"
#include "lib/film.h"
#include "test.h"
+#include <boost/filesystem.hpp>
+#include <boost/test/unit_test.hpp>
using std::cout;
using std::cerr;
*/
test ("prophet_clip.mkv", 23.976, 12);
}
-
*/
+#include "lib/file_log.h"
#include <boost/test/unit_test.hpp>
-#include "lib/log.h"
using std::cout;