Backstage 디버깅
Backstage 디버깅 (Debugging Backstage)
로컬에서 Backstage를 처음 구성하거나 새 코드 변경을 기여할 때 로깅 수준을 변경하면 시스템이 어떻게 작동하는지 더 잘 이해하는 데 도움이 될 수 있습니다.
출처: 문서
본문
로컬에서 Backstage를 처음 구성하거나 새 코드 변경을 기여할 때 로깅 수준을 변경하면 시스템이 어떻게 작동하는지 더 잘 이해하는 데 도움이 될 수 있습니다.
Backstage는 Winston 로깅 라이브러리를 사용하며 warn, info(기본값), debug 같은 npm 로깅 수준을 지원합니다.
로깅 인스턴스는 플러그인에도 전달되어 플러그인이 자체 처리에 대한 정보를 노출할 수 있게 합니다.
수준 변경은 LOG_LEVEL 환경 변수를 설정해 할 수 있습니다.
예를 들어 로컬에서 앱을 실행할 때 디버그 로그를 켜려면 다음을 실행할 수 있습니다.
LOG_LEVEL=debug yarn start
결과 로그에는 이제 디버깅에 사용할 수 있는 더 많은 정보가 있어야 합니다.
[1] 2023-04-12T00:51:42.468Z catalog debug Skipped stitching of domain:default/artists, no changes type=plugin[1] 2023-04-12T00:51:42.469Z catalog debug Skipped stitching of domain:default/playback, no changes type=plugin[1] 2023-04-12T00:51:42.470Z catalog debug Processing system:default/podcast type=plugin[1] 2023-04-12T00:51:42.470Z catalog debug Processing group:default/infrastructure type=plugin[1] 2023-04-12T00:51:42.470Z catalog debug Processing group:default/boxoffice type=plugin[1] 2023-04-12T00:51:42.470Z catalog debug Processing group:default/backstage type=plugin[1] 2023-04-12T00:51:42.470Z catalog debug Processing group:default/team-a type=plugin[1] 2023-04-12T00:51:42.519Z catalog debug Skipped stitching of group:default/acme-corp, no changes type=plugin[1] 2023-04-12T00:51:42.520Z catalog debug Skipped stitching of group:default/backstage, no changes type=plugin[1] 2023-04-12T00:51:42.521Z catalog debug Skipped stitching of group:default/boxoffice, no changes type=plugin[1] 2023-04-12T00:51:42.523Z catalog debug Processing user:default/breanna.davison type=plugin[1] 2023-04-12T00:51:42.524Z catalog debug Processing user:default/janelle.dawe type=plugin[1] 2023-04-12T00:51:42.524Z catalog debug Processing user:default/nigel.manning type=plugin[1] 2023-04-12T00:51:42.524Z catalog debug Processing user:default/guest type=plugin[1] 2023-04-12T00:51:42.525Z catalog debug Processing group:default/team-b type=plugin[1] 2023-04-12T00:51:44.057Z search info Starting collation of explore tools type=plugin[1] 2023-04-12T00:51:44.095Z backstage info ::1 - - [12/Apr/2023:00:51:44 +0000] \"GET /api/explore/tools HTTP/1.1\" 200 - \"-\" \"node-fetch/1.0 (+https://github.com/bitinn/node-fetch)\" type=incomingRequest[1] 2023-04-12T00:51:44.100Z backstage info ::1 - - [12/Apr/2023:00:51:44 +0000] \"GET /api/catalog/entities?filter=metadata.annotations.backstage.io%2Ftechdocs-ref&fields=kind,namespace,metadata.annotations,metadata.name,metadata.title,metadata.namespace,spec.typ... [truncated]
디버거 (Debugger)
VSCode
.vscode/launch.json에 다음으로 새 항목을 추가하세요.
{ "configurations": [ { "name": "Start Backstage", // The name of this configuration, displayed in the Run and Debug panel. "type": "node", // Specifies that this is a Node.js debugging configuration. "request": "launch", // Indicates that the debugger should launch the application (as opposed to attaching to an already running process). "cwd": "${workspaceFolder}", // Sets the current working directory to the root of the workspace. "runtimeExecutable": "yarn", // Specifies the runtime to execute the application. In this case, it uses `yarn` to run the script. "args": ["start", "--inspect"], // Arguments passed to the `yarn` command. Here, it runs `yarn start` with the `--inspect` flag to enable debugging. "skipFiles": ["<node_internals>/**"], // Tells the debugger to skip stepping into Node.js internal files during debugging. "console": "integratedTerminal", // Specifies that the debugger should use the integrated terminal for input/output. "experimentalNetworking": "off" // Since Node.js 22.15.0 an additional parameter --experimental-network-inspection is added but currently not supported by Yarn } ]}
다양한 목적을 위해 여러 구성을 추가할 수 있습니다.
자세한 내용은 VSCode 문서를 참조하세요.
WebStorm
이 섹션은 WebStorm에서 Backstage용 실행 구성을 활성화하는 과정을 설명합니다. 실행 구성을 사용하면 스테퍼와 중단점 같은 디버깅 기능을 사용할 수 있습니다.
Run드롭다운 메뉴에서Edit Configurations를 선택합니다. 더하기 기호를 클릭해 새 구성을 추가한 다음Node.js를 선택합니다.Working directory에{PROJECT_DIR}/packages/backend를 입력합니다.{PROJECT_DIR}을 Backstage 저장소 경로로 바꾸세요.JavaScript file에{PROJECT_DIR}/node_modules/@backstage/cli/bin/backstage-cli를 입력합니다.{PROJECT_DIR}을 Backstage 저장소 경로로 바꾸세요.Application parameters에package start를 입력합니다.- 선택적으로
Environment Variables에LOG_LEVEL=debug를 입력합니다. - 변경 사항을 저장하려면
Apply를 클릭합니다. - 새로 만든 구성을 선택한 상태로 툴바의
Run또는Debug아이콘을 사용해 새로 만든 구성을 실행합니다.