From d907d5d268b470c7f461cb0b7951b894e4b77772 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 22 Jan 2015 13:31:31 -0500 Subject: [PATCH] Avoid using NSLog() where we can --- ActiveSync/NSData+ActiveSync.m | 9 +++++---- ActiveSync/SOGoActiveSyncDispatcher+Sync.m | 10 +++++----- ActiveSync/SOGoActiveSyncDispatcher.m | 5 +++-- Main/SOGo.m | 4 ++-- Main/sogod.m | 8 ++++---- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ActiveSync/NSData+ActiveSync.m b/ActiveSync/NSData+ActiveSync.m index 34fa4da95..7114403cc 100644 --- a/ActiveSync/NSData+ActiveSync.m +++ b/ActiveSync/NSData+ActiveSync.m @@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import +#import #include #include @@ -48,7 +49,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. path = [NSString stringWithFormat: @"/tmp/%@.data", [[NSProcessInfo processInfo] globallyUniqueString]]; [self writeToFile: path atomically: YES]; - NSLog(@"Original data written to: %@", path); + [self errorWithFormat: @"Original data written to: %@", path]; } // @@ -81,7 +82,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (ret != WBXML_OK) { - NSLog(@"wbxml2xmlFromContent: failed: %s\n", wbxml_errors_string(ret)); + [self errorWithFormat: @"wbxml2xmlFromContent: failed: %s\n", wbxml_errors_string(ret)]; [self _dumpToFile]; return nil; } @@ -114,7 +115,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (ret != WBXML_OK) { - NSLog(@"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret)); + [self logWithFormat: @"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret)]; [self _dumpToFile]; return nil; } @@ -129,7 +130,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (ret != WBXML_OK) { - NSLog(@"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret)); + [self errorWithFormat: @"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret)]; [self _dumpToFile]; free(wbxml); wbxml_conv_xml2wbxml_destroy(conv); diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m index 6a6f44d89..5f4502bc2 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m +++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m @@ -57,6 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import +#import #import #import @@ -287,9 +288,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. case ActiveSyncMailFolder: default: { - // FIXME - //continue; - NSLog(@"BLARG!"); + // FIXME - what to do? + [self errorWithFormat: @"Fatal error occured - tried to call -processSyncAddCommand: ... on a mail folder. We abort."]; abort(); } } @@ -1405,12 +1405,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (changeDetected) { - NSLog(@"Change detected, we push the content."); + [self logWithFormat: @"Change detected, we push the content."]; break; } else { - NSLog(@"Sleeping %d seconds while detecting changes...", internalInterval); + [self logWithFormat: @"Sleeping %d seconds while detecting changes...", internalInterval]; sleep(internalInterval); } } diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index 393e192b8..5ce7a4d29 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -59,6 +59,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import #import +#import #import #import @@ -1872,13 +1873,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if ([foldersWithChanges count]) { - NSLog(@"Change detected, we push the content."); + [self logWithFormat: @"Change detected, we push the content."]; status = 2; break; } else { - NSLog(@"Sleeping %d seconds while detecting changes...", internalInterval); + [self logWithFormat: @"Sleeping %d seconds while detecting changes...", internalInterval]; sleep(internalInterval); } } diff --git a/Main/SOGo.m b/Main/SOGo.m index c3b015771..8e8959b2c 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -245,7 +245,7 @@ static BOOL debugLeaks; } else { - NSLog (@"No value specified for '%@'", *urlString); + [self errorWithFormat: @"No value specified for '%@'", *urlString]; ok = NO; } } @@ -441,7 +441,7 @@ static BOOL debugLeaks; if (debugLeaks) { if (debugOn) - NSLog (@"allocated classes:\n%s", GSDebugAllocationList (YES)); + [self logWithFormat: @"allocated classes:\n%s", GSDebugAllocationList (YES)]; else { debugOn = YES; diff --git a/Main/sogod.m b/Main/sogod.m index 4a123b938..4d6a488ae 100644 --- a/Main/sogod.m +++ b/Main/sogod.m @@ -1,15 +1,15 @@ /* Copyright (C) 2004-2005 SKYRIX Software AG - Copyright (C) 2006-2009 Inverse inc. + Copyright (C) 2006-2015 Inverse inc. - This file is part of OpenGroupware.org. + This file is part of SOGo. - OGo is free software; you can redistribute it and/or modify it under + SOGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - OGo is distributed in the hope that it will be useful, but WITHOUT ANY + SOGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.