CastDebugLogger API를 사용하면
웹 수신기 디버그 오버레이를 다른 색상으로 표시합니다. 다음과 같은 로그 메서드를 사용합니다.
가장 높은 우선순위에서 가장 낮은 우선순위 순으로 나열됩니다.
castDebugLogger.error(custom_tag, message);
castDebugLogger.warn(custom_tag, message);
castDebugLogger.info(custom_tag, message);
castDebugLogger.debug(custom_tag, message);
각 로그 메서드에서 첫 번째 매개변수는 맞춤 태그여야 하고
두 번째 매개변수는 로그 메시지입니다.
태그는 유용하다고 생각되는 문자열이면 무엇이든 사용할 수 있습니다.
다음은 LOAD 인터셉터에서 디버그 로거를 사용하는 방법을 보여주는 예입니다.
constLOG_TAG='MyReceiverApp';playerManager.setMessageInterceptor(cast.framework.messages.MessageType.LOAD,request=>{castDebugLogger.debug(LOG_TAG,'Intercepting LOAD request');returnnewPromise((resolve,reject)=>{fetchMediaAsset(request.media.contentId).then(data=>{letitem=data[request.media.contentId];if(!item){castDebugLogger.error(LOG_TAG,'Content not found');reject();}else{request.media.contentUrl=item.stream.hls;castDebugLogger.info(LOG_TAG,'Playable URL:',request.media.contentUrl);resolve(request);}});});});
로그
각 맞춤 태그에 대한 loggerLevelByTags의 수준입니다. 예를 들어
로그 수준이 cast.framework.LoggerLevel.DEBUG인 맞춤 태그가 다음과 같이 표시됩니다.
오류, 경고, 정보, 디버그 로그 메시지와 함께 추가된 모든 메시지 다른
WARNING 수준의 맞춤 태그를 사용 설정하면
오류 및 로그 메시지 경고를 표시합니다
loggerLevelByTags 구성은 선택사항입니다. 맞춤 태그가 구성되지 않은 경우
모든 로그 메시지가 디버그 오버레이에 표시됩니다.
constLOG_TAG1='Tag1';constLOG_TAG2='Tag2';//SetverbositylevelforcustomtagscastDebugLogger.loggerLevelByTags={[LOG_TAG1]:cast.framework.LoggerLevel.WARNING,[LOG_TAG2]:cast.framework.LoggerLevel.DEBUG,};castDebugLogger.debug(LOG_TAG1,'debug log from tag1');castDebugLogger.info(LOG_TAG1,'info log from tag1');castDebugLogger.warn(LOG_TAG1,'warn log from tag1');castDebugLogger.error(LOG_TAG1,'error log from tag1');castDebugLogger.debug(LOG_TAG2,'debug log from tag2');castDebugLogger.info(LOG_TAG2,'info log from tag2');castDebugLogger.warn(LOG_TAG2,'warn log from tag2');castDebugLogger.error(LOG_TAG2,'error log from tag2');//exampleoutputs://[Tag1][WARN]warnlogfromtag1//[Tag1][ERROR]errorlogfromtag1//[Tag2][DEBUG]debuglogfromtag2//[Tag2][INFO]infologfromtag2//[Tag2][WARN]warnlogfromtag2//[Tag2][ERROR]errorlogfromtag2
디버그 오버레이
Cast 디버그 로거는 웹 수신기에 디버그 오버레이를 제공하여
맞춤 로그 메시지를 작성합니다 showDebugLogs를 사용하여 디버그 오버레이 전환
및 clearDebugLogs를 사용하여 오버레이에서 로그 메시지를 지웁니다.
알림: CastDebugLogger가 설정된 후 showDebugLogs 및 clearDebugLogs를 사용하세요.
사용 설정되어 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eThe CastDebugLogger API enables developers to debug their Web Receiver app alongside the Command and Control (CaC) tool for capturing logs, requiring Cast device registration and firmware version 1.44 or above.\u003c/p\u003e\n"],["\u003cp\u003eInitialization involves including specific scripts for the Web Receiver SDK and the Cast Debug Logger, creating a CastDebugLogger object, enabling it within the 'READY' event listener, and ensuring \u003ccode\u003esetEnabled\u003c/code\u003e is set to false for production.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can log player events using the \u003ccode\u003eloggerLevelByEvents\u003c/code\u003e config, specifying event types and categories for logging with different verbosity levels like INFO or DEBUG.\u003c/p\u003e\n"],["\u003cp\u003eCustom log messages with custom tags are supported using methods like \u003ccode\u003eerror\u003c/code\u003e, \u003ccode\u003ewarn\u003c/code\u003e, \u003ccode\u003einfo\u003c/code\u003e, and \u003ccode\u003edebug\u003c/code\u003e, with the ability to control message visibility through the \u003ccode\u003eloggerLevelByTags\u003c/code\u003e configuration.\u003c/p\u003e\n"],["\u003cp\u003eThe debug overlay, toggled with \u003ccode\u003eshowDebugLogs\u003c/code\u003e and cleared with \u003ccode\u003eclearDebugLogs\u003c/code\u003e, displays log messages and is activated after enabling the CastDebugLogger.\u003c/p\u003e\n"]]],["The CastDebugLogger API allows debugging Web Receiver apps. To use it, include the debug script after the Web Receiver SDK script and instantiate `CastDebugLogger`. Enable it with `setEnabled(true)` to display a \"DEBUG MODE\" overlay. Log player events using `loggerLevelByEvents` and custom messages with `error`, `warn`, `info`, or `debug` methods, assigning custom tags. Set tag-specific log levels with `loggerLevelByTags`. Manage the overlay using `showDebugLogs` and `clearDebugLogs`. Remember to register your device and change setEnabled to **false** for production.\n"],null,["# Cast Debug Logger\n\nThe Web Receiver SDK provides the CastDebugLogger API for developers to easily\ndebug their Web Receiver app and a companion\n[Command and Control (CaC) Tool](/cast/docs/debugging/cac_tool) to capture\nlogs.\n| **Note:** To use the CastDebugLogger API, you must [register your Cast device](/cast/docs/registration) on the [Google Cast SDK Developer Console](https://cast.google.com/publish) and use a firmware version of **1.44** or above.\n\nInitialization\n--------------\n\nTo use the **CastDebugLogger API**, include the following script in your\nWeb Receiver app right after the Web Receiver SDK script: \n\n \u003c!-- Web Receiver SDK --\u003e\n \u003cscript src=\"//www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js\"\u003e\u003c/script\u003e\n \u003c!-- Cast Debug Logger --\u003e\n \u003cscript src=\"//www.gstatic.com/cast/sdk/libs/devtools/debug_layer/caf_receiver_logger.js\"\u003e\u003c/script\u003e\n\nCreate the `CastDebugLogger` object and enable the logger: \n\n const castDebugLogger = cast.debug.CastDebugLogger.getInstance();\n\n const context = cast.framework.CastReceiverContext.getInstance();\n\n context.addEventListener(cast.framework.system.EventType.READY, () =\u003e {\n if (!castDebugLogger.debugOverlayElement_) {\n // Enable debug logger and show a 'DEBUG MODE' overlay at top left corner.\n castDebugLogger.setEnabled(true);\n }\n });\n\n| **Warning:** Make sure to change `setEnabled` to **false** for a production receiver.\n\nWhen the debug logger is enabled, an overlay displaying **DEBUG MODE** will\nshow on the receiver.\n\nLog Player Events\n-----------------\n\nUsing `CastDebugLogger` you can easily log player events that are fired by\nthe Web Receiver SDK and use different logger levels to log the event data.\nThe `loggerLevelByEvents` config takes [`cast.framework.events.EventType`](/cast/docs/reference/caf_receiver/cast.framework.events#.EventType)\nand [`cast.framework.events.category`](/cast/docs/reference/caf_receiver/cast.framework.events.category)\nto specify the events to be logged.\n\nFor example, if you want to know when the player `CORE` events are triggered\nor a `mediaStatus` change is broadcasted, use the following config to log the\nevents: \n\n castDebugLogger.loggerLevelByEvents = {\n 'cast.framework.events.category.CORE': cast.framework.LoggerLevel.INFO,\n 'cast.framework.events.EventType.MEDIA_STATUS': cast.framework.LoggerLevel.DEBUG\n }\n\nLog Custom Messages with Custom Tags\n------------------------------------\n\nThe CastDebugLogger API allows you to create log messages that appear on\nthe Web Receiver debug overlay with different colors. Use the following log methods,\nlisted in order from highest to lowest priority:\n\n- `castDebugLogger.error(custom_tag, message);`\n- `castDebugLogger.warn(custom_tag, message);`\n- `castDebugLogger.info(custom_tag, message);`\n- `castDebugLogger.debug(custom_tag, message);`\n\nFor each log method, the first parameter should be a **custom tag** and\nthe second parameter is the **log message**.\nThe tag can be any string that you find helpful.\n\nHere is an example of how to use the debug logger in the `LOAD` interceptor. \n\n const LOG_TAG = 'MyReceiverApp';\n\n playerManager.setMessageInterceptor(\n cast.framework.messages.MessageType.LOAD,\n request =\u003e {\n castDebugLogger.debug(LOG_TAG, 'Intercepting LOAD request');\n\n return new Promise((resolve, reject) =\u003e {\n fetchMediaAsset(request.media.contentId).then(\n data =\u003e {\n let item = data[request.media.contentId];\n if (!item) {\n castDebugLogger.error(LOG_TAG, 'Content not found');\n\n reject();\n } else {\n request.media.contentUrl = item.stream.hls;\n castDebugLogger.info(LOG_TAG,\n 'Playable URL:', request.media.contentUrl);\n\n resolve(request);\n }\n }\n );\n });\n }\n );\n\nYou can control which messages appear on the debug overlay by setting the log\nlevel in `loggerLevelByTags` for each custom tag. For example, enabling a\ncustom tag with log level `cast.framework.LoggerLevel.DEBUG` would display\nall messages added with error, warn, info, and debug log messages. Another\nexample is that enabling a custom tag with `WARNING` level would only display\nerror and warn log messages.\n\nThe `loggerLevelByTags` config is optional. If a custom tag is not configured\nfor its logger level, all log messages will display on the debug overlay. \n\n const LOG_TAG1 = 'Tag1';\n const LOG_TAG2 = 'Tag2';\n\n // Set verbosity level for custom tags\n castDebugLogger.loggerLevelByTags = {\n [LOG_TAG1]: cast.framework.LoggerLevel.WARNING,\n [LOG_TAG2]: cast.framework.LoggerLevel.DEBUG,\n };\n castDebugLogger.debug(LOG_TAG1, 'debug log from tag1');\n castDebugLogger.info(LOG_TAG1, 'info log from tag1');\n castDebugLogger.warn(LOG_TAG1, 'warn log from tag1');\n castDebugLogger.error(LOG_TAG1, 'error log from tag1');\n\n castDebugLogger.debug(LOG_TAG2, 'debug log from tag2');\n castDebugLogger.info(LOG_TAG2, 'info log from tag2');\n castDebugLogger.warn(LOG_TAG2, 'warn log from tag2');\n castDebugLogger.error(LOG_TAG2, 'error log from tag2');\n\n // example outputs:\n // [Tag1] [WARN] warn log from tag1\n // [Tag1] [ERROR] error log from tag1\n // [Tag2] [DEBUG] debug log from tag2\n // [Tag2] [INFO] info log from tag2\n // [Tag2] [WARN] warn log from tag2\n // [Tag2] [ERROR] error log from tag2\n\nDebug Overlay\n-------------\n\nThe Cast Debug Logger provides a **debug overlay** on the Web Receiver to show\nyour custom log messages. Use `showDebugLogs` to toggle the debug overlay\nand `clearDebugLogs` to clear log messages on the overlay.\n\nReminder: use `showDebugLogs` and `clearDebugLogs` after castDebugLogger is\nenabled. \n\n const context = cast.framework.CastReceiverContext.getInstance();\n\n context.addEventListener(cast.framework.system.EventType.READY, () =\u003e {\n if (!castDebugLogger.debugOverlayElement_) {\n // Enable debug logger and show a 'DEBUG MODE' overlay at top left corner.\n castDebugLogger.setEnabled(true);\n // Show debug overlay\n castDebugLogger.showDebugLogs(true);\n // Clear log messages on debug overlay\n castDebugLogger.clearDebugLogs();\n }\n });"]]