어느 Salesforce Developer의 개발 성장기

Developer Console 기본편(4)-Inspect Objects at Checkpoints 본문

Salesforce/Developer Tools

Developer Console 기본편(4)-Inspect Objects at Checkpoints

Developer_Foryou 2020. 3. 9. 19:58

Set Checkpoints in your apex code

Checkpoint는 code가 실행되는 과정의 특정 부분에서 어떤 일이 일어나는지 snapshot을 보여준다.

Let's set a checkpoint

  1. Select File | Open, and open the EmailMissionSpecialist class.
  2. Select Debug | Change Log Levels.
  3. In the General Trace Settings for You section, click Add/Change.
  4. Set the ApexCode log level to FINEST.
  5. To save your changes, click Done.
  6. To exit the Change Log Levels dialog box, click Done.

※ 주의

  • Checkpoint를 설정하기 위해서 당신은 모든 데이터를 볼 수 있는 사용자 권한이 필요하다.
  • Checkpoint를 사용하여 결과를 발생시키기 위해 execute anonymous window에서 실행하거나 DEVELOPER_LOG trace flag를 설정해야한다.
  • Trace flag는 log level이 INFO이상이어야한다.


Source Code 왼쪽의 Code Line을 클릭하여 Checkpoint를 만들면, Checkpoints tab에서 확인할 수 있다.

Checkpoints tab

Checkpoints tab을 통해서 코드의 실행이 잘못되고있는 지점과 그 시점에있는 객체의 값을 정확히 볼 수 있다.
ex. 위 이미지와 같이 Source Code 왼쪽의 Code Line을 클릭하여 Checkpoint를 만든 후, Debug | Open Execute Anonymous Window에서 다음 코드를 실행하면 Checkpoints tab에서 확인할 수 있다.
(Enter your email address 대신에 확인할 수 있는 이메일 주소 입력)

EmailMissionSpecialist em = new EmailMissionSpecialist();
em.sendMail('Enter your email address', 'Flight Path Change',
'Mission Control 123: Your flight path has been changed to avoid collision '
+ 'with asteroid 2014 QO441.');

Checkpoints 표에서 checkpoint를 더블 클릭하면 캡쳐된 결과 값을 볼 수 있다.

Checkpoint inspector

Checkpoints에는 Heap tab과 Sysbols tab이 있다.
Heap - 실행 된 코드 줄에서 메모리에 있는 모든 개체를 표시
Sysbols - 메모리의 모든 Sysbol을 Tree view로 표시
Heap Tab

Heap tab에는 Types 패널과 같은 디버깅을 위한 패널이 포함되어 있다. 이 패널은 얼마나 많은 객체가 인스턴스화되었고 그들이 소비 한 메모리를 바이트 단위로 보여준다.

  1. Under Types, click Messaging.SingleEmailMessage.
  2. Under Instances, click any instance of this object type.
  3. Under State, view the object’s fields and their values.

Symbols Tab

Symbols 탭은 모든 Checkpoint에서 다양한 Object의 상태를 빠르고 간단하게 검토 할 수있는 방법이다.
Symbol은 특정 Obejct를 참조하는 고유한 이름이다. 이 탭은 Tree view를 사용하여 메모리에 있는 모든 Symbol을 표시한다.

※ 주의
Checkpoint Result는 Checkpoint 설정한 코드가 실행되지 않으면 Checkpoints가 생성되지 않는다.

Comments