forcedotcom / SalesforceMobileSDK-iOS

iOS SDK for Salesforce
Other
538 stars 421 forks source link

Cannot disable logging #2057

Closed mikecaulley closed 7 years ago

mikecaulley commented 7 years ago
  1. Version of Mobile SDK Used: 5.1
  2. Issue found in Native App or Hybrid App: Native App, Smart Sync Example
  3. OS Version: 10.3.2
  4. Device: iPhone 7
  5. Steps to reproduce: Edit the debug level line in AppDelegate init to always have [SFLogger sharedLogger].logLevel = SFLogLevelOff;
  6. Actual behavior: I still see log information in the output window.
  7. Expected Behavior: I expect not to see any logging information.
trooper2013 commented 7 years ago

@mikecaulley Do you see log statements from salesforce components? e.g. <Datetime AppName LEVEL com.salesforce.*> We can control logging for mobile-sdk components only.

mikecaulley commented 7 years ago

@trooper2013 I am running the SmartSyncExplorer with nearly zero changes, and I see logs like:

2017-05-22 16:08:50.445844-0400 SmartSyncExplorer[84959:1647906] syncDown:{
  "status" : "NEW",
  "target" : {
    "idFieldName" : "Id",
    "modificationDateFieldName" : "LastModifiedDate",
    "iOSImpl" : "SFSoqlSyncDownTarget",
    "type" : "soql",
    "query" : "SELECT LastModifiedDate, Id,FirstName,LastName,Title,MobilePhone,Email,Department,HomePhone FROM Contact LIMIT 10000"
  },
  "_soupEntryId" : 9,
  "maxTimeStamp" : 0,
  "totalSize" : -1,
  "type" : "syncDown",
  "progress" : 0,
  "options" : {
    "mergeMode" : "LEAVE_IF_CHANGED"
  },
  "soupName" : "contacts"
}
2017-05-22 16:08:50.446961-0400 SmartSyncExplorer[84959:1647906] Sync update:{
  "status" : "RUNNING",
  "target" : {
    "idFieldName" : "Id",
    "modificationDateFieldName" : "LastModifiedDate",
    "iOSImpl" : "SFSoqlSyncDownTarget",
    "type" : "soql",
    "query" : "SELECT LastModifiedDate, Id,FirstName,LastName,Title,MobilePhone,Email,Department,HomePhone FROM Contact LIMIT 10000"
  },
  "_soupEntryId" : 9,
  "maxTimeStamp" : 0,
  "totalSize" : -1,
  "type" : "syncDown",
  "progress" : 0,
  "options" : {
    "mergeMode" : "LEAVE_IF_CHANGED"
  },
  "soupName" : "contacts"
}
2017-05-22 16:08:50.448628-0400 SmartSyncExplorer[84959:1648921] sendRequestWithSmartSyncUserAgent:request:<SFRestRequest 0x6080000c9fb0 
endpoint: /services/data 
method: GET 
path: /v39.0/query 
queryParams: {
  "q" : "SELECT LastModifiedDate, Id,FirstName,LastName,Title,MobilePhone,Email,Department,HomePhone FROM Contact LIMIT 10000"
} 
>
2017-05-22 16:08:51.262 SmartSyncExplorer[84959:1647906] A background URLSession with identifier com.salesforce.network already exists!
2017-05-22 16:08:51.767363-0400 SmartSyncExplorer[84959:1649094] sendRequestWithSmartSyncUserAgent:error:400:https://salesforce.com/services/data/v39.0/query?q=SELECT-0x8.00070000a79249p-7233stModifiedDate,20Id,FirstName,LastName,Title,MobilePhone,Email,Department,HomePhone            0.000000ROM                   ontact20LIMIT2010000
2017-05-22 16:08:51.767845-0400 SmartSyncExplorer[84959:1649094] runSync failed:{
  "status" : "RUNNING",
  "target" : {
    "idFieldName" : "Id",
    "modificationDateFieldName" : "LastModifiedDate",
    "iOSImpl" : "SFSoqlSyncDownTarget",
    "type" : "soql",
    "query" : "SELECT LastModifiedDate, Id,FirstName,LastName,Title,MobilePhone,Email,Department,HomePhone FROM Contact LIMIT 10000"
  },
  "_soupEntryId" : 9,
  "maxTimeStamp" : 0,
  "totalSize" : -1,
  "type" : "syncDown",
  "progress" : 0,
  "options" : {
    "mergeMode" : "LEAVE_IF_CHANGED"
  },
  "soupName" : "contacts"
} cause:Server call for sync down failed errorError Domain=https://salesforce.com/services/data/v39.0/query?q=SELECT0xf.fff9efffff98a4p+6918stModifiedDate,20Id,FirstName,LastName,Title,MobilePhone,Email,Department,HomePhone            0.000000ROM                   ontact20LIMITode=400 "(null)" UserInfo={error=(
        {
        errorCode = "INVALID_FIELD";
        message = "\nTitle,MobilePhone,Email,Department,HomePhone FROM Contact LIMIT 10000\n                                   ^\nERROR at Row:1:Column:83\nNo such column 'HomePhone' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.";
    }
)}
2017-05-22 16:08:51.769207-0400 SmartSyncExplorer[84959:1649094] Sync update:{
  "status" : "FAILED",
  "target" : {
    "idFieldName" : "Id",
    "modificationDateFieldName" : "LastModifiedDate",
    "iOSImpl" : "SFSoqlSyncDownTarget",
    "type" : "soql",
    "query" : "SELECT LastModifiedDate, Id,FirstName,LastName,Title,MobilePhone,Email,Department,HomePhone FROM Contact LIMIT 10000"
  },
  "_soupEntryId" : 9,
  "maxTimeStamp" : 0,
  "totalSize" : -1,
  "type" : "syncDown",
  "progress" : 0,
  "options" : {
    "mergeMode" : "LEAVE_IF_CHANGED"
  },
  "soupName" : "contacts"
}
wmathurin commented 7 years ago

Log level for sync related messages can be set by doing:

        [SFSyncManagerLogger setLevel:SFLogLevelXXX];
wmathurin commented 7 years ago

So to completely disable logging in 5.1, you need to do:

        [SFLogger sharedLogger].logLevel = SFLogLevelOff;
        [SFSyncManagerLogger setLevel:SFLogLevelOff];
michaelcaulley commented 7 years ago

@wmathurin
I already tried doing [SFLogger sharedLogger].logLevel = SFLogLevelOff; [SFSyncManagerLogger sharedLogger].logLevel = SFLogLevelOff;

And I still see the logs. What am I doing incorrectly? I assume when you said [SFSyncManagerLogger SFLogLevelOff]; you meant [SFSyncManagerLogger sharedLogger].logLevel = SFLogLevelOff;

wmathurin commented 7 years ago

I meant setLevel: (see my first comment).

michaelcaulley commented 7 years ago

That doesn't seem to work either. Also [SFSyncManagerLogger setLogLevel:SFLogLevelOff]; gives a deprecated warning, and says to use [SFLogger sharedLogger].logLevel

wmathurin commented 7 years ago

Something is off indeed ;-) Thanks for reporting the issue. We have created a bug for it and we will look into it.

michaelcaulley commented 7 years ago

Thanks!

wmathurin commented 7 years ago

Fixed in dev by the PR.

matthes commented 4 years ago

This issue seems to be reintroduced in latest code. Setting log level does not have any effect, value of the logLevel property is never read in SFDefaultLogger. I had to create custom subclass and set it using setInstanceClass:. I made very simple fix in - (void)log:(Class)cls level:(SFLogLevel)level message:(NSString *)message method:

if(level >= self.logLevel) {
        const char *tag = [[NSString stringWithFormat:@"CLASS: %@", cls] cStringUsingEncoding:NSUTF8StringEncoding];
        const char * messageZ = [message cStringUsingEncoding:NSUTF8StringEncoding];
        os_log_with_type(self.logger, level,"%{public}s %{public}s",tag,messageZ);
    }

This does the trick, however I guess it should be supported out of the box without having to do such hacks :)

dessmith commented 8 months ago

Do the newer versions of the SDK fix this yet?