]> granicus.if.org Git - handbrake/commitdiff
MacGui: modify writeToActivityLog to use vargs
authordynaflash <dynaflashtech@gmail.com>
Tue, 8 Jan 2008 18:05:30 +0000 (18:05 +0000)
committerdynaflash <dynaflashtech@gmail.com>
Tue, 8 Jan 2008 18:05:30 +0000 (18:05 +0000)
- thanks travistex
- can now accept input like: [self writeToActivityLog: "trying to open a package at: %s", [path UTF8String]];

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1176 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.h
macosx/Controller.mm

index fc0cdfc427313a17583bb231af136641236075b1..565f63b07bca6ce1f517059d73c0125f2428242e 100644 (file)
     BOOL                           SuccessfulScan;
        NSString                      * currentSource;
 }
-- (void) writeToActivityLog:(char *) activityMessage;
+- (void) writeToActivityLog:(char *) format, ...;
 - (IBAction) browseSources: (id) sender;
 - (void) browseSourcesDone: (NSOpenPanel *) sheet
                 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
index 7a109eff3375ef29fa14d1e684168c7374cd06db..7152a20feea92e434d6b12986ea50a25aeedcf64 100644 (file)
@@ -767,11 +767,20 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 }
 
 /* We use this to write messages to stderr from the macgui which show up in the activity window and log*/
-- (void) writeToActivityLog:(char *) activityMessage
+- (void) writeToActivityLog:(char *) format, ...
 {
-    time_t _now = time( NULL );
-    struct tm * now  = localtime( &_now );
-    fprintf(stderr, "[%02d:%02d:%02d] MacGui: %s\n", now->tm_hour, now->tm_min, now->tm_sec, activityMessage );
+    va_list args;
+    va_start(args, format);
+    if (format != nil)
+    {
+        char str[1024];
+        vsnprintf( str, 1024, format, args );
+
+        time_t _now = time( NULL );
+        struct tm * now  = localtime( &_now );
+        fprintf(stderr, "[%02d:%02d:%02d] MacGui: %s\n", now->tm_hour, now->tm_min, now->tm_sec, str );
+    }
+    va_end(args);
 }
 
 #pragma mark -
@@ -1138,7 +1147,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             /* We check to see if the chosen file at path is a package */
             if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:path])
             {
-                [self writeToActivityLog:"trying to open a package"];
+                [self writeToActivityLog: "trying to open a package at: %s", [path UTF8String]];
                 /* We check to see if this is an .eyetv package */
                 if ([[path pathExtension] isEqualToString: @"eyetv"])
                 {
@@ -1167,7 +1176,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                 else
                 {
                     /* The package is not an eyetv package, so we do not call performScan */
-                    [self writeToActivityLog:"unable to open package"];
+                    //[self writeToActivityLog:"unable to open package"];
                 }
             }
             else