summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2004-12-18 13:14:52 +0000
committerpixel <pixel>2004-12-18 13:14:52 +0000
commitc262889aa1fcf72dac3ee6697de52ce6efe8f894 (patch)
treed21009d97fd623d1739bbb6bda020823aeee65bf
parentfa2e3d6b2c07ac250e1dc1c82d17193949014dc1 (diff)
Adding log system into cd-tool.
-rw-r--r--cd-tool.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/cd-tool.cpp b/cd-tool.cpp
index 6242402..2affbf4 100644
--- a/cd-tool.cpp
+++ b/cd-tool.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: cd-tool.cpp,v 1.36 2004-12-13 20:06:36 pixel Exp $ */
+/* $Id: cd-tool.cpp,v 1.37 2004-12-18 13:14:52 pixel Exp $ */
#define WIP
@@ -344,6 +344,7 @@ struct option long_options[] = {
{"exec", 1, NULL, 'e'},
{"built-in", 0, NULL, 'b'},
{"probe", 0, NULL, 'p'},
+ {"log", 1, NULL, 'g'},
{0, 0, NULL, 0 }
};
@@ -413,6 +414,7 @@ void showhelp(bool longhelp = false) {
" -e <cmd> to execute this single command in LUA.\n"
" -b to force the use of the built-in cd-tool.lua\n"
" -p to run a CD device probe.\n"
+" -g <log> to log into a file.\n"
" -h for a help page.\n"
, argv[0]);
@@ -448,6 +450,22 @@ void probe(void) {
}
}
+class cd_tool_printer_t : public printer_t {
+ public:
+ cd_tool_printer_t(Handle * h) : log(h) { }
+ virtual bool printm(int level, const char * format, va_list ap) {
+ char tmp[10241];
+
+ vsprintf(tmp, format, ap);
+
+ (*log) << tmp;
+
+ return true;
+ }
+ private:
+ Handle * log;
+};
+
virtual int startup() throw (GeneralException) {
char c;
@@ -467,7 +485,7 @@ virtual int startup() throw (GeneralException) {
/* Let's start parsing options */
- while ((c = getopt_long(argc, argv, "Hhvf:wo:a:c:dile:pb", long_options, NULL)) != EOF) {
+ while ((c = getopt_long(argc, argv, "Hhvf:wo:a:c:dile:pbg:", long_options, NULL)) != EOF) {
switch (c) {
case 'h':
case 'H':
@@ -512,6 +530,9 @@ virtual int startup() throw (GeneralException) {
case 'b':
builtin = true;
break;
+ case 'g':
+ printer = new cd_tool_printer_t(new Output(optarg));
+ break;
default:
showhelp();
throw Exit(-1);