Nice programing

이상한 원치 않는 Xcode 로그 숨기기

nicepro 2020. 9. 30. 11:28
반응형

이상한 원치 않는 Xcode 로그 숨기기


Xcode 8+를 사용하고 비어있는 새 프로젝트를 만들 때 응용 프로그램을 실행할 때 다음 로그가 나타납니다.

2016-06-13 16:33:34.406093 TestiOS10[8209:100611] bundleid: com.appc.TestiOS10, enable_level: 0, persist_level: 0, propagate_with_activity: 0
2016-06-13 16:33:34.406323 TestiOS10[8209:100607] Created DB, header sequence number = 248
2016-06-13 16:33:34.409564 TestiOS10[8209:100611] subsystem: com.apple.UIKit, category: HIDEvents, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-13 16:33:34.504117 TestiOS10[8209:100607] Created DB, header sequence number = 248
2016-06-13 16:33:34.548023 TestiOS10[8209:100607] subsystem: com.apple.BaseBoard, category: MachPort, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0
2016-06-13 16:33:34.568458 TestiOS10[8209:100608] subsystem: com.apple.FrontBoard, category: Common, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0

누군가 이미 이것을 처리 할 구성을 찾았 을까요?


이 시도:

1- Xcode 메뉴 열기 : 제품> 구성표> 구성표 편집

2- 환경 변수 세트 OS_ACTIVITY_MODE=disable

스크린 샷


@rustyshelf 의 원래 트윗 과 iDevzilla의 그림 된 답변을 기반으로 여기에 장치에서 NSLog 출력을 비활성화하지 않고 시뮬레이터의 소음을 차단하는 솔루션이 있습니다.

  1. Product> Scheme> Edit Scheme ...> Run (Debug)에서 OS_ACTIVITY_MODE 환경 변수를 $ {DEBUG_ACTIVITY_MODE}로 설정하여 다음과 같이 보이게합니다.

여기에 이미지 설명 입력

  1. 프로젝트 빌드 설정으로 이동하고 +를 클릭하여 DEBUG_ACTIVITY_MODE라는 사용자 정의 설정을 추가합니다. 이 설정을 확장하고 디버그 옆에있는 +를 클릭하여 플랫폼 별 값을 추가합니다. 드롭 다운을 선택하고 "모든 iOS 시뮬레이터"로 변경합니다. 그런 다음 값을 "disable"로 설정하여 다음과 같이 보이게합니다.

여기에 이미지 설명 입력


OS_ACTIVITY_MODE가 나에게 적합하지 않았 거나 ( 오타 를 입력 했기 때문일 있지만 더 자연스럽지 않습니까?!?), 적어도 많은 메시지를 차단하지 않았습니다. 그래서 여기에 환경 변수에 대한 실제 거래가 있습니다.disabledisabled

https://llvm.org/svn/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

lldb_private::Error
PlatformDarwin::LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) {
  // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr
  // if the OS_ACTIVITY_DT_MODE environment variable is set.  (It doesn't
  // require any specific value; rather, it just needs to exist).
  // We will set it here as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag
  // is not set.  Xcode makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell
  // LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they
  // specifically want it unset.
  const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE";
  auto &env_vars = launch_info.GetEnvironmentEntries();
  if (!env_vars.ContainsEnvironmentVariable(disable_env_var)) {
    // We want to make sure that OS_ACTIVITY_DT_MODE is set so that
    // we get os_log and NSLog messages mirrored to the target process
    // stderr.
    if (!env_vars.ContainsEnvironmentVariable("OS_ACTIVITY_DT_MODE"))
      env_vars.AppendArgument(llvm::StringRef("OS_ACTIVITY_DT_MODE=enable"));
  }

  // Let our parent class do the real launching.
  return PlatformPOSIX::LaunchProcess(launch_info);
}

따라서 OS_ACTIVITY_DT_MODE환경 변수 (주 답변의 Schemes 스크린 샷에 설명 된 GUI 방법)에서 "NO"로 설정 하면 작동합니다.

마찬가지로 지금까지와 같은 NSLog시스템 메시지, 오류 및 자신의 디버깅에 대한 덤핑 지상되는 : 실제 로깅 방법은 아마도, 예를 들어, 어쨌든 호출됩니다 https://github.com/fpillet/NSLogger .

또는

새로운 Kool-Aid를 마셔보세요 : http://asciiwwdc.com/2016/sessions/721 https://developer.apple.com/videos/play/wwdc2016/721/ 전체를 점검 한 후 약간의 장애가 있다는 것은 놀라운 일이 아닙니다. 로깅 API.

추가

어쨌든, NSLog그냥 심입니다.

https://developer.apple.com/library/content/releasenotes/Miscellaneous/RN-Foundation-OSX10.12/

NSLog / CFLog

NSLog는 이제 대부분의 상황에서 os_log에 대한 shim입니다.

이제 다른 env 변수에 대한 소스를 인용하는 것이 의미가 있습니다. 이번에는 Apple 내부에서 상당히 다른 곳입니다. 왜 그들이 겹치는 지 잘 모르겠습니다. [ NSLog삭제 에 대한 잘못된 댓글 ]

[9 월 22 일 수정] : "릴리스"와 "스트림"이 "디버그"와 다른 점이 무엇인지 궁금합니다. 출처가 충분하지 않습니다.

https://github.com/macosforge/libdispatch/blob/8e63547ea4e5abbfe55c0c3064181c4950a791d3/src/voucher.c

e = getenv("OS_ACTIVITY_MODE");
if (e) {
    if (strcmp(e, "release") == 0) {
        mode = voucher_activity_mode_release;
    } else if (strcmp(e, "debug") == 0) {
        mode = voucher_activity_mode_debug;
    } else if (strcmp(e, "stream") == 0) {
        mode = voucher_activity_mode_stream;
    } else if (strcmp(e, "disable") == 0) {
        mode = voucher_activity_mode_disable;
    }
}

트윗 나를 위해 대답을했다 - https://twitter.com/rustyshelf/status/775505191160328194

Xcode 8 iOS 시뮬레이터가 미친 듯이 로깅되는 것을 중지하려면 디버그 체계에서 환경 변수 OS_ACTIVITY_MODE = disable을 설정하십시오.

효과가있었습니다.


이것은 여전히 ​​Xcode 버전 8.0 베타 2 (8S162m)에서 수정되지 않았으며 Xcode 콘솔에도 추가 로그가 나타납니다.

** 8/1/16 편집 : 이것은 Xcode 8 Beta 4 (8S188o)릴리스 노트에서 여전히 문제가 지속되는 것으로 확인되었습니다 .

Xcode 8 베타 4 – IDE의 알려진 문제

디버깅

• Xcode 디버그 콘솔은 시뮬레이터에서 애플리케이션을 디버깅 할 때 시스템 프레임 워크의 추가 로깅을 표시합니다. (27331147, 26652255)

아마도 이것은 GM 릴리스에 의해 해결 될 것입니다. 그때까지 인내심과 이상적이지는 않지만 내가 사용하는 해결 방법은 다음과 같습니다.

이전 답변과 유사하게 다음을 수행해야합니다.

  • 내 인쇄 로그에 특수 문자 (예 : * 또는 ^ 또는! 등)를 붙이십시오.

  • 그런 다음 콘솔 창의 오른쪽 하단에있는 검색 상자를 사용하여 선택한 특수 문자를 입력하여 콘솔 로그를 필터링하여 콘솔이 의도 한대로 인쇄 로그를 표시하도록합니다.

콘솔


아래 단계를 찾으십시오.

  1. 제품 => 체계 => 체계 편집을 선택하거나 바로 가기를 사용하십시오. CMD + <
  2. Run왼쪽 에서 옵션을 선택하십시오 .
  3. 환경 변수 섹션에서 OS_ACTIVITY_MODE = disable 변수를 추가합니다.

자세한 내용은 아래 GIF 표현을 참조하십시오.

구성표 편집


내 솔루션은 중단 점에서 디버거 명령 및 / 또는 로그 메시지 를 사용하는 것 입니다.

여기에 이미지 설명 입력

그리고에서 콘솔의 출력을 변경할 모든 출력디버거 출력

여기에 이미지 설명 입력


좋구나. 이것에 대해 많은 소동이있는 것 같으니, 그 계획 트릭을 사용하지 않고 지속 할 수있는 방법을 알려 드리겠습니다. iOS 시뮬레이터에 대해 구체적으로 설명하겠습니다.하지만 다른 디렉토리에있는 TV Sim에도 적용해야 할 수도 있습니다.

이 모든 것을 일으키는 문제는 Xcode 디렉토리에있는 plist입니다. Sim이 시작될 때 configd_sim 이라는 프로세스가 시작 되어 plist를 읽고 plist가 로깅해야한다고 지정하면 디버깅 정보를 인쇄합니다.

plist는 다음 위치에 있습니다.

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Preferences/Logging/Subsystems

베타 버전을 사용하는 경우 디렉토리가 다를 수 있습니다.

이 디렉토리에는 수많은 plist가 있습니다. 이제 애플리케이션을 빌드 및 실행하고 로그를 관찰하십시오. 서브 시스템 : 부분 바로 뒤에 오는 컨텐츠를 찾고 있습니다. 해당 문제가있는 plist를 나타내는 것은 바로 뒤에 오는 이름입니다.

여기에 이미지 설명 입력

거기에서 plist를 수정하여 키 / 값을 포함하는 딕셔너리 인 디버깅 [Level] 키 / 값을 제거 "Enable" => "Default"하거나 단순히 plist를 삭제하십시오. Xcode 응용 프로그램에 있기 때문에 이러한 작업을 수행하려면 루트 여야합니다.

plutil -p명령은 사용자에게도 유용 할 수 있습니다.

plutil -p /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Preferences/Logging/Subsystems/com.apple.BackBoardServices.fence.plist

이것은 다음을 포함하는 문제가있는 plist 중 하나를 제공했습니다.

{ "DEFAULT-OPTIONS" => { "Level" => { "Enable" => "Default" }}}

행운을 빕니다 :]


This is related to a known issue with logging found in the Xcode 8 Beta Release Notes (also asked an engineer at WWDC).

When debugging WatchOS applications in the Watch simulator, the OS may produce an excessive amount of unhelpful logging. (26652255)

There is currently no workaround available, you must wait for a new version of Xcode.

EDIT 7/5/16: This is supposedly fixed as of Xcode 8 Beta 2:

Resolved in Xcode 8 beta 2 – IDE

Debugging

  • When debugging an app on the Simulator, logs are visible. (26457535)

Xcode 8 Beta 2 Release Notes


This is no longer an issue in xcode 8.1 (tested Version 8.1 beta (8T46g)). You can remove the OS_ACTIVITY_MODE environment variable from your scheme.

https://developer.apple.com/go/?id=xcode-8.1-beta-rn

Debugging

• Xcode Debug Console no longer shows extra logging from system frameworks when debugging applications in the Simulator. (26652255, 27331147)


In Xcode 10 the OS_ACTIVITY_MODE variable with disable (or default) value also turns off the NSLog no matter what.

So if you want to get rid of the console noise but not of your own logs, you could try the good old printf("") instead of the NSLog since it is not affected by the OS_ACTIVITY_MODE = disable.

But better check out the new os_log API here.


This solution has been working for me:

  1. Run the app in the simulator
  2. Open the system log ( + /)

This will dump out all of the debug data and also your NSLogs.

To filter just your NSLog statements:

  1. Prefix each with a symbol, for example: NSLog(@"^ Test Log")
  2. 오른쪽 상단의 검색 창, 위의 경우 "^"를 사용하여 결과를 필터링합니다.

이것은 당신이 얻는 것입니다 :

콘솔 스크린 샷

참고 URL : https://stackoverflow.com/questions/37800790/hide-strange-unwanted-xcode-logs

반응형