diff options
author | Pierre Ossman <ossman@cendio.se> | 2016-04-20 09:38:06 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2019-04-29 14:14:00 +0200 |
commit | e9e7da9b7adcf33dece522514c323d392913041b (patch) | |
tree | 1c179f451b8ecd43bad1bef5543dfe2c81b2f488 /common/rdr | |
parent | 0fb3e3519558531a64f345726e414998f7d9dc5a (diff) | |
download | tigervnc-e9e7da9b7adcf33dece522514c323d392913041b.tar.gz tigervnc-e9e7da9b7adcf33dece522514c323d392913041b.zip |
Do proper logging rather than fprintf(stderr, ...)
Diffstat (limited to 'common/rdr')
-rw-r--r-- | common/rdr/RandomStream.cxx | 9 | ||||
-rw-r--r-- | common/rdr/ZlibOutStream.cxx | 19 |
2 files changed, 17 insertions, 11 deletions
diff --git a/common/rdr/RandomStream.cxx b/common/rdr/RandomStream.cxx index 3fde18d1..e22da3d0 100644 --- a/common/rdr/RandomStream.cxx +++ b/common/rdr/RandomStream.cxx @@ -18,6 +18,7 @@ #include <rdr/RandomStream.h> #include <rdr/Exception.h> +#include <rfb/LogWriter.h> #include <time.h> #include <stdlib.h> #ifndef WIN32 @@ -30,6 +31,8 @@ #endif #endif +static rfb::LogWriter vlog("RandomStream"); + using namespace rdr; const int DEFAULT_BUF_LEN = 256; @@ -46,11 +49,11 @@ RandomStream::RandomStream() if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) { if (GetLastError() == (DWORD)NTE_BAD_KEYSET) { if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { - fprintf(stderr, "RandomStream: unable to create keyset\n"); + vlog.error("unable to create keyset"); provider = 0; } } else { - fprintf(stderr, "RandomStream: unable to acquire context\n"); + vlog.error("unable to acquire context"); provider = 0; } } @@ -65,7 +68,7 @@ RandomStream::RandomStream() { #endif #endif - fprintf(stderr,"RandomStream: warning: no OS supplied random source - using rand()\n"); + vlog.error("no OS supplied random source - using rand()"); seed += (unsigned int) time(0) + getpid() + getpid() * 987654 + rand(); srand(seed); } diff --git a/common/rdr/ZlibOutStream.cxx b/common/rdr/ZlibOutStream.cxx index 9d9f8ba1..dd3c2367 100644 --- a/common/rdr/ZlibOutStream.cxx +++ b/common/rdr/ZlibOutStream.cxx @@ -21,11 +21,14 @@ #include <rdr/ZlibOutStream.h> #include <rdr/Exception.h> +#include <rfb/LogWriter.h> #include <zlib.h> #undef ZLIBOUT_DEBUG +static rfb::LogWriter vlog("ZlibOutStream"); + using namespace rdr; enum { DEFAULT_BUF_SIZE = 16384 }; @@ -85,7 +88,7 @@ void ZlibOutStream::flush() zs->avail_in = ptr - start; #ifdef ZLIBOUT_DEBUG - fprintf(stderr,"zos flush: avail_in %d\n",zs->avail_in); + vlog.debug("flush: avail_in %d",zs->avail_in); #endif // Force out everything from the zlib encoder @@ -98,7 +101,7 @@ void ZlibOutStream::flush() int ZlibOutStream::overrun(int itemSize, int nItems) { #ifdef ZLIBOUT_DEBUG - fprintf(stderr,"zos overrun\n"); + vlog.debug("overrun"); #endif if (itemSize > bufSize) @@ -120,7 +123,7 @@ int ZlibOutStream::overrun(int itemSize, int nItems) } else { // but didn't consume all the data? try shifting what's left to the // start of the buffer. - fprintf(stderr,"z out buf not full, but in data not consumed\n"); + vlog.info("z out buf not full, but in data not consumed"); memmove(start, zs->next_in, ptr - zs->next_in); offset += zs->next_in - start; ptr -= zs->next_in - start; @@ -149,8 +152,8 @@ void ZlibOutStream::deflate(int flush) zs->avail_out = underlying->getend() - underlying->getptr(); #ifdef ZLIBOUT_DEBUG - fprintf(stderr,"zos: calling deflate, avail_in %d, avail_out %d\n", - zs->avail_in,zs->avail_out); + vlog.debug("calling deflate, avail_in %d, avail_out %d", + zs->avail_in,zs->avail_out); #endif rc = ::deflate(zs, flush); @@ -163,8 +166,8 @@ void ZlibOutStream::deflate(int flush) } #ifdef ZLIBOUT_DEBUG - fprintf(stderr,"zos: after deflate: %d bytes\n", - zs->next_out-underlying->getptr()); + vlog.debug("after deflate: %d bytes", + zs->next_out-underlying->getptr()); #endif underlying->setptr(zs->next_out); @@ -177,7 +180,7 @@ void ZlibOutStream::checkCompressionLevel() if (newLevel != compressionLevel) { #ifdef ZLIBOUT_DEBUG - fprintf(stderr,"zos change: avail_in %d\n",zs->avail_in); + vlog.debug("change: avail_in %d",zs->avail_in); #endif // zlib is just horribly stupid. It does an implicit flush on |