From 746173279e3f612a65cf006f2bd98332c1fc97af Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sun, 12 May 2002 11:16:24 +0000 Subject: [PATCH] 2002-05-12 Robert Collins * LogFile.cc (endLog): Work around an apparent libg++-3 bug causing corrupt log file entries. * geturl.cc: Convert to the new LogSingleton logging. --- ChangeLog | 6 ++++++ LogFile.cc | 9 +++++++-- geturl.cc | 19 ++++++++++--------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8e85c0c..554c93fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-05-12 Robert Collins + + * LogFile.cc (endLog): Work around an apparent libg++-3 bug causing + corrupt log file entries. + * geturl.cc: Convert to the new LogSingleton logging. + 2002-05-12 Robert Collins * ini.cc (do_remote_ini): Use setup.bz2 if it exists in preference to diff --git a/LogFile.cc b/LogFile.cc index be027857..38d1a04d 100644 --- a/LogFile.cc +++ b/LogFile.cc @@ -29,6 +29,7 @@ static const char *cvsid = #include #include #include +#include /* private helper class */ class filedef @@ -184,11 +185,15 @@ LogFile::endEntry() strftime (b, 1000, "%Y/%m/%d %H:%M:%S ", tm); currEnt->msg = b; } - currEnt->msg += theStream->str(); - msg ("LOG: %d %s", currEnt->level, theStream->str()); + /* What follows is a hack to get around an (apparent) bug in libg++-3 with + * non-0 memory on alloc + */ + currEnt->msg += string(theStream->str()).substr(0,theStream->pcount()).c_str(); + msg ("LOG: %d %s", currEnt->level, string(theStream->str()).substr(0,theStream->rdbuf()->pcount()).c_str()); theStream->freeze(0); delete theStream; /* reset for next use */ theStream = new ostrstream; rdbuf (theStream->rdbuf()); + init (theStream->rdbuf()); } diff --git a/geturl.cc b/geturl.cc index 1564e6d8..8371cf9e 100644 --- a/geturl.cc +++ b/geturl.cc @@ -36,7 +36,6 @@ static const char *cvsid = #include "resource.h" #include "netio.h" #include "msg.h" -#include "log.h" #include "io_stream.h" #include "io_stream_memory.h" #include "state.h" @@ -49,6 +48,8 @@ static const char *cvsid = #include "Exception.h" +#include "LogSingleton.h" + extern ThreeBarProgressPage Progress; static int max_bytes = 0; @@ -116,14 +117,14 @@ progress (int bytes) void getUrlToStream (String const &_url, HWND owner, io_stream *output) { - log (LOG_BABBLE, String ("getUrlToStream ") + _url); + log (LOG_BABBLE) << "getUrlToStream " << _url << endLog; is_local_install = (source == IDC_SOURCE_CWD); init_dialog (_url, 0, owner); NetIO *n = NetIO::open (_url.cstr_oneuse()); if (!n || !n->ok ()) { delete n; - log (LOG_BABBLE, "getUrlToStream failed!"); + log (LOG_BABBLE) << "getUrlToStream failed!" << endLog; throw new Exception ("__LINE__ __FILE__", "Error opening url", APPERR_IO_ERROR); } @@ -160,14 +161,14 @@ get_url_to_membuf (String const &_url, HWND owner) io_stream_memory *membuf = new io_stream_memory (); try { - log (LOG_BABBLE, String ("get_url_to_membuf ") + _url); + log (LOG_BABBLE) << "get_url_to_membuf " << _url << endLog; getUrlToStream (_url, owner, membuf); if (membuf->seek (0, IO_SEEK_SET)) { if (membuf) delete membuf; - log (LOG_BABBLE, "get_url_to_membuf(): seek (0) failed for membuf!"); + log (LOG_BABBLE) << "get_url_to_membuf(): seek (0) failed for membuf!" << endLog; return 0; } return membuf; @@ -176,7 +177,7 @@ get_url_to_membuf (String const &_url, HWND owner) { if (e->errNo() != APPERR_IO_ERROR) throw e; - log (LOG_BABBLE, "get_url_to_membuf failed!"); + log (LOG_BABBLE) << "get_url_to_membuf failed!" << endLog; delete membuf; return 0; } @@ -194,7 +195,7 @@ get_url_to_string (String const &_url, HWND owner) { /* zero length, or error retrieving length */ delete stream; - log (LOG_BABBLE, "get_url_to_string(): couldn't retrieve buffer size, or zero length buffer"); + log (LOG_BABBLE) << "get_url_to_string(): couldn't retrieve buffer size, or zero length buffer" << endLog; return String(); } char temp [bytes + 1]; @@ -209,7 +210,7 @@ int get_url_to_file (String const &_url, String const &_filename, int expected_length, HWND owner, BOOL allow_ftp_auth) { - log (LOG_BABBLE, String ("get_url_to_file ") + _url + " " + _filename); + log (LOG_BABBLE) << "get_url_to_file " << _url << " " << _filename << endLog; if (total_download_bytes > 0) { int df = diskfull (get_root_dir ().cstr_oneuse()); @@ -223,7 +224,7 @@ get_url_to_file (String const &_url, String const &_filename, int expected_lengt if (!n || !n->ok ()) { delete n; - log (LOG_BABBLE, "get_url_to_file failed!"); + log (LOG_BABBLE) << "get_url_to_file failed!" << endLog; return 1; } -- 2.43.5