Revision: 12381
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12381&view=rev
Author:   amaxwell
Date:     2008-01-08 18:04:02 -0800 (Tue, 08 Jan 2008)

Log Message:
-----------
add more detailed logging, enabled with a separate define

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconCache.mm

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconCache.mm
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconCache.mm    2008-01-09 
01:47:13 UTC (rev 12380)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIconCache.mm    2008-01-09 
02:04:02 UTC (rev 12381)
@@ -41,6 +41,7 @@
 #import "DTCharArray.h"
 #import "zlib.h"
 #import <sys/stat.h>
+#import <asl.h>
 
 static CGImageRef FVCreateCGImageWithCharArray(DTCharArray array);
 static DTCharArray FVCharArrayWithCGImage(CGImageRef image);
@@ -51,6 +52,10 @@
 static char *__tempName = NULL;        /* only a file static for debugging */
 static pthread_mutex_t __dataFileLock = PTHREAD_MUTEX_INITIALIZER;
 
+#ifndef ENABLE_CACHE_LOGGING
+#define ENABLE_CACHE_LOGGING 0
+#endif
+
 + (void)initialize
 {
     static BOOL didInit = NO;
@@ -79,7 +84,7 @@
         __dataFile = new DTDataFile(__tempName);
         
         // unlink the file immediately; since DTDataFile calls fopen() in its 
constructor, this is safe, and means we don't leave turds when the program 
crashes.  For debug builds, the file is unlinked when the app terminates, since 
otherwise the call to stat() fails with a file not found error (presumably 
since the link count is zero).
-#ifndef DEBUG
+#if !(ENABLE_CACHE_LOGGING)
         unlink(__tempName);
 #endif
         [[NSNotificationCenter defaultCenter] addObserver:self 
@@ -102,13 +107,19 @@
     
     pthread_mutex_unlock(&__dataFileLock);
     
-#ifdef DEBUG
+#if ENABLE_CACHE_LOGGING
     // print the file size, just because I'm curious about it (before 
unlinking the file, though!)
     struct stat sb;
     if (0 == stat(__tempName, &sb)) {
         off_t fsize = sb.st_size;
         double mbSize = double(fsize) / 1024 / 1024;
-        NSLog(@"*** removing %s with cache size %.2f MB", __tempName, mbSize);
+        
+        aslclient client = asl_open("FileViewCache", NULL, ASL_OPT_NO_DELAY);
+        aslmsg m = asl_new(ASL_TYPE_MSG);
+        asl_set(m, ASL_KEY_SENDER, "FileViewCache");
+        asl_log(client, m, ASL_LEVEL_ERR, "removing %s with cache size = %.2f 
MB\n", __tempName, mbSize);
+        asl_free(m);
+        asl_close(client);
     }
     else {
         string errMsg = string("stat failed \"") + __tempName + "\"";
@@ -148,6 +159,14 @@
 + (void)cacheCGImage:(CGImageRef)image withName:(const char *)name;
 {
     DTCharArray array = FVCharArrayWithCGImage(image);
+#if ENABLE_CACHE_LOGGING
+    aslclient client = asl_open("FileViewCache", NULL, ASL_OPT_NO_DELAY);
+    aslmsg m = asl_new(ASL_TYPE_MSG);
+    asl_set(m, ASL_KEY_SENDER, "FileViewCache");
+    asl_log(client, m, ASL_LEVEL_ERR, "caching image for %s, size = %.2f 
kBytes\n", name, double(array.Length()) / 1024);
+    asl_free(m);
+    asl_close(client);
+#endif
     pthread_mutex_lock(&__dataFileLock);
     if (__dataFile) __dataFile->Save(array, name);
     pthread_mutex_unlock(&__dataFileLock);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to