Why xcode 8 (iOS 10) prints [LogMessageLogging] <private> in console

Why does Xcode 8 (iOS 10) print [LogMessageLogging] <private>to the console when I call the map view?
can anyone give some suggestions?

Thank you very much!

Screen shot

+4
source share
2 answers

Confidentiality

. , . , , , public. , %{public}s.


(ObjC):

os_log_t log = os_log_create("com.example.my-subsystem", "test");

const char *staticString = "I am static string!";
const char *dynamicString = [[NSString stringWithFormat:@"I am %@!", @"dynamic string"]
                             cStringUsingEncoding:NSUTF8StringEncoding];

os_log(log, "Message: %s", staticString);
os_log(log, "Message: %s", dynamicString);
os_log(log, "Message: %{public}s", dynamicString);

// Output
// [test] Message: I am static string!
// [test] Message: <private>
// [test] Message: I am dynamic string!

(Swift):

Swift (https://openradar.appspot.com/radar?id=6068967584038912), C Swift:

// File: os_log_rdar28599032.h
#import <Foundation/Foundation.h>
#import <os/log.h>

void log_private(os_log_t, os_log_type_t, NSString *);
void log_public(os_log_t, os_log_type_t, NSString *);


// File: os_log_rdar28599032.m
#import "os_log_rdar28599032.h"

void log_private(os_log_t log, os_log_type_t type, NSString * message) {
   os_log_with_type(log, type, "%s", [message cStringUsingEncoding:NSUTF8StringEncoding]);
}

void log_public(os_log_t log, os_log_type_t type, NSString * message) {
   os_log_with_type(log, type, "%{public}s", [message cStringUsingEncoding:NSUTF8StringEncoding]);
}


// File: ViewController.swift
import Cocoa
import os.log
import os.activity

class ViewController: NSViewController {

   static let log = OSLog(subsystem: "com.example.my-subsystem", category: "test")
   typealias SelfClass = ViewController

   override func viewDidLoad() {
      super.viewDidLoad()
      log_private(SelfClass.log, .fault, "I am dynamic \("string")!")
      log_public(SelfClass.log, .fault, "I am dynamic \("string")!")
      log_private(SelfClass.log, .fault, #file)
      log_public(SelfClass.log, .fault, #file)
   }

}

// Output
// [test] <private>
// [test] I am dynamic string!
// [test] <private>
// [test] /[REDACTED]/ViewController.swift
+5

MacOS 10.12 (Sierra),

, , .

, , - os_log, . 'private' , , :

$ sudo log config --mode "level:debug" --subsystem com.your_company.your_subsystem_name

UPDATE:

@SunilChauhan, . NSLog , . : API os_log, promises:

API- os_log C, Objective-C Swift. , . , , , , , .

, , , -.

+1

All Articles