{"id":42214,"date":"2023-09-28T03:17:34","date_gmt":"2023-09-27T19:17:34","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=42214"},"modified":"2023-09-28T03:17:34","modified_gmt":"2023-09-27T19:17:34","slug":"dhsyztsgj","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/42214.html","title":{"rendered":"DebugToFile\u51fd\u6570\uff1a\u4e00\u79cd\u8c03\u8bd5\u5de5\u5177"},"content":{"rendered":"

  DebugToFile\u51fd\u6570\u662f\u4e00\u79cd\u8c03\u8bd5\u5de5\u5177\uff0c\u7528\u4e8e\u5c06\u8c03\u8bd5\u4fe1\u606f\u8f93\u51fa\u5230\u6587\u672c\u6587\u4ef6\u4e2d\uff0c\u4ee5\u4fbf\u8fdb\u884c\u540e\u7eed\u5206\u6790\u548c\u5904\u7406\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u7a0b\u5e8f\u5458\u5feb\u901f\u5b9a\u4f4d\u7a0b\u5e8f\u4e2d\u7684\u95ee\u9898\uff0c\u4ece\u800c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u8d28\u91cf\u548c\u6548\u7387\u3002<\/p>\n

DebugToFile\u51fd\u6570\u7684\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5<\/h2>\n

  DebugToFile\u51fd\u6570\u7684\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u7a0b\u5e8f\u4e2d\u6dfb\u52a0\u4e00\u884c\u4ee3\u7801\u5373\u53ef\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8981\u5c06\u8c03\u8bd5\u4fe1\u606f\u8f93\u51fa\u5230\u6587\u4ef6\u201cdebug.log\u201d\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n

DebugToFile(\"debug.log\", \"This is a debug message\");<\/code><\/pre>\n

  \u5982\u679c\u8981\u5c06\u8c03\u8bd5\u4fe1\u606f\u8f93\u51fa\u5230\u6587\u4ef6\u201cdebug.log\u201d\u4e2d\uff0c\u5e76\u4e14\u5728\u8c03\u8bd5\u4fe1\u606f\u4e2d\u5305\u542b\u53d8\u91cf\u7684\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n

int x = 10; DebugToFile(\"debug.log\", \"x = %d\", x);<\/code><\/pre>\n

  \u4e0a\u8ff0\u4ee3\u7801\u5c06\u5728\u6587\u4ef6\u201cdebug.log\u201d\u4e2d\u8f93\u51fa\u201cx = 10\u201d\u3002<\/p>\n

DebugToFile\u51fd\u6570\u7684\u9ad8\u7ea7\u4f7f\u7528\u65b9\u6cd5<\/h2>\n

  1. \u8bb0\u5f55\u591a\u884c\u8c03\u8bd5\u4fe1\u606f<\/h3>\n

  DebugToFile\u51fd\u6570\u53ef\u4ee5\u8bb0\u5f55\u591a\u884c\u8c03\u8bd5\u4fe1\u606f\uff0c\u53ea\u9700\u8981\u5728\u8c03\u7528DebugToFile\u51fd\u6570\u65f6\u4f20\u5165\u591a\u4e2a\u53c2\u6570\u5373\u53ef\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8981\u5c06\u4e24\u884c\u8c03\u8bd5\u4fe1\u606f\u8f93\u51fa\u5230\u6587\u4ef6\u201cdebug.log\u201d\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n

DebugToFile(\"debug.log\", \"This is the first line of debug message\",  \"This is the second line of debug message\");<\/code><\/pre>\n

  2. \u8bb0\u5f55\u590d\u6742\u7684\u8c03\u8bd5\u4fe1\u606f<\/h3>\n

  DebugToFile\u51fd\u6570\u8fd8\u53ef\u4ee5\u8bb0\u5f55\u590d\u6742\u7684\u8c03\u8bd5\u4fe1\u606f\uff0c\u4f8b\u5982\u591a\u7ef4\u6570\u7ec4\u3001\u7ed3\u6784\u4f53\u7b49\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8981\u5c06\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u7684\u5185\u5bb9\u8f93\u51fa\u5230\u6587\u4ef6\u201cdebug.log\u201d\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n

int array[2][2] = { {1, 2}, {3, 4} }; DebugToFile(\"debug.log\", \"array = %d %d %d %d\", array[0][0], array[0][1], array[1][0], array[1][1]);<\/code><\/pre>\n

\u603b\u7ed3<\/h2>\n

  DebugToFile\u51fd\u6570\u662f\u4e00\u79cd\u975e\u5e38\u6709\u7528\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u7a0b\u5e8f\u5458\u5feb\u901f\u5b9a\u4f4d\u7a0b\u5e8f\u4e2d\u7684\u95ee\u9898\uff0c\u4ece\u800c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u8d28\u91cf\u548c\u6548\u7387\u3002<\/strong>\u5b83\u7684\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ef\u4ee5\u8bb0\u5f55\u591a\u884c\u8c03\u8bd5\u4fe1\u606f\uff0c\u4e5f\u53ef\u4ee5\u8bb0\u5f55\u590d\u6742\u7684\u8c03\u8bd5\u4fe1\u606f\uff0c\u5982\u591a\u7ef4\u6570\u7ec4\u548c\u7ed3\u6784\u4f53\u7b49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

DebugToFile\u51fd\u6570\u662f\u4e00\u79cd\u8c03\u8bd5\u5de5\u5177\uff0c\u7528\u4e8e\u5c06\u8c03\u8bd5\u4fe1\u606f\u8f93\u51fa\u5230\u6587\u672c\u6587\u4ef6\u4e2d\uff0c\u4ee5\u4fbf\u8fdb\u884c\u540e\u7eed\u5206\u6790\u548c\u5904\u7406\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u7a0b\u5e8f\u5458\u5feb\u901f\u5b9a\u4f4d\u7a0b\u5e8f\u4e2d\u7684\u95ee\u9898\uff0c\u4ece\u800c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u8d28\u91cf\u548c\u6548\u7387\u3002<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[305],"class_list":["post-42214","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-dzjs"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/42214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=42214"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/42214\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=42214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=42214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=42214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}