{"id":2916,"date":"2024-11-10T15:45:57","date_gmt":"2024-11-10T07:45:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2916\/"},"modified":"2024-11-10T15:45:57","modified_gmt":"2024-11-10T07:45:57","slug":"nodejs-%e4%b8%ad%e7%9a%84%e6%97%a5%e5%bf%97%e8%ae%b0%e5%bd%95%e5%92%8c%e7%9b%91%e6%8e%a7%ef%bc%9a%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2916\/","title":{"rendered":"Nodejs \u4e2d\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\uff1a\u6700\u4f73\u5b9e\u8df5"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173094049091827.jpg\" class=\"aligncenter\" title=\"Nodejs \u4e2d\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\uff1a\u6700\u4f73\u5b9e\u8df5\u63d2\u56fe\" alt=\"Nodejs \u4e2d\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\uff1a\u6700\u4f73\u5b9e\u8df5\u63d2\u56fe\" \/><\/p>\n<p>\u6709\u6548\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\u5bf9\u4e8e\u7ef4\u62a4\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u72b6\u51b5\u3001\u5feb\u901f\u8bc6\u522b\u95ee\u9898\u548c\u63d0\u9ad8\u6027\u80fd\u81f3\u5173\u91cd\u8981\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8 node.js \u5e94\u7528\u7a0b\u5e8f\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\uff0c\u6db5\u76d6\u9009\u62e9\u65e5\u5fd7\u8bb0\u5f55\u7ea7\u522b\u3001\u8bbe\u7f6e\u7ed3\u6784\u5316\u65e5\u5fd7\u3001\u4e0e\u76d1\u63a7\u5de5\u5177\u96c6\u6210\u4ee5\u53ca\u4f7f\u7528 winston \u548c elasticsearch \u7684\u6700\u4f73\u5b9e\u8df5\u7b49\u5173\u952e\u4e3b\u9898\u3002<\/p>\n<h2> \u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\u7b80\u4ecb <\/h2>\n<p>\u65e5\u5fd7\u8bb0\u5f55\u6709\u52a9\u4e8e\u6355\u83b7\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u5b9e\u65f6\u4e8b\u4ef6\u3001\u9519\u8bef\u548c\u5176\u4ed6\u91cd\u8981\u4fe1\u606f\uff0c\u800c\u76d1\u63a7\u5219\u6d89\u53ca\u8ddf\u8e2a\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u5e94\u7528\u7a0b\u5e8f\u6027\u80fd\u6307\u6807\u3002\u5b83\u4eec\u5171\u540c\u63d0\u4f9b\u4e86\u6709\u5173\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u72b6\u51b5\u7684\u91cd\u8981\u89c1\u89e3\uff0c\u4ece\u800c\u80fd\u591f\u4e3b\u52a8\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<h2> \u5728 node.js \u4e2d\u8bbe\u7f6e\u57fa\u672c\u65e5\u5fd7\u8bb0\u5f55 <\/h2>\n<p>\u5185\u7f6e\u7684\u63a7\u5236\u53f0\u5bf9\u8c61\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\uff0c\u4f46\u4e13\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5e93\u5bf9\u4e8e\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f\u6765\u8bf4\u66f4\u52a0\u5f3a\u5927\u3002 <\/p>\n<h3> \u57fa\u672c\u63a7\u5236\u53f0\u65e5\u5fd7\u8bb0\u5f55 <\/h3>\n<pre>console.log(\"server started on port 3000\");\nconsole.warn(\"this is a warning\");\nconsole.error(\"error occurred while processing request\");\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f46\u662f\uff0c\u63a7\u5236\u53f0\u65e5\u5fd7\u8bb0\u5f55\u5728\u590d\u6742\u5e94\u7528\u4e2d\u5b58\u5728\u5c40\u9650\u6027\uff0c\u4f8b\u5982\u7f3a\u4e4f\u65e5\u5fd7\u7ea7\u522b\u63a7\u5236\u4ee5\u53ca\u6ca1\u6709\u65e5\u5fd7\u6301\u4e45\u5316\u3002<\/p>\n<h3> \u6e29\u65af\u987f\u4ecb\u7ecd <\/h3>\n<p>winston \u662f\u4e00\u4e2a\u6d41\u884c\u7684 node.js \u65e5\u5fd7\u5e93\uff0c\u63d0\u4f9b\u591a\u4e2a\u65e5\u5fd7\u7ea7\u522b\u3001\u4f20\u8f93\uff08\u65e5\u5fd7\u76ee\u7684\u5730\uff09\u548c\u7ed3\u6784\u5316\u65e5\u5fd7\u8bb0\u5f55\u3002<\/p>\n<ol>\n<li>\u5b89\u88c5\u6e29\u65af\u987f\uff1a <\/li>\n<\/ol>\n<pre>   npm install winston\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u8bbe\u7f6e\u6e29\u65af\u987f <\/li>\n<\/ol>\n<pre>   const winston = require(\"winston\");\n\n   \/\/ configure logger\n   const logger = winston.createlogger({\n       level: \"info\",\n       format: winston.format.combine(\n           winston.format.timestamp(),\n           winston.format.json()\n       ),\n       transports: [\n           new winston.transports.console(),\n           new winston.transports.file({ filename: \"app.log\" })\n       ]\n   });\n\n   \/\/ logging examples\n   logger.info(\"server started on port 3000\");\n   logger.error(\"database connection failed\");\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h2> \u9009\u62e9\u9002\u5f53\u7684\u65e5\u5fd7\u7ea7\u522b <\/h2>\n<p>\u65e5\u5fd7\u7ea7\u522b\u6839\u636e\u65e5\u5fd7\u6d88\u606f\u7684\u91cd\u8981\u6027\u5bf9\u5176\u8fdb\u884c\u5206\u7c7b\u3002\u5e38\u89c1\u7684\u65e5\u5fd7\u7ea7\u522b\u6709\uff1a<\/p>\n<ul>\n<li> <strong>\u9519\u8bef<\/strong>\uff1a\u9700\u8981\u7acb\u5373\u5173\u6ce8\u7684\u4e25\u91cd\u95ee\u9898\uff0c\u4f8b\u5982\u6570\u636e\u5e93\u6216\u670d\u52a1\u5668\u6545\u969c\u3002<\/li>\n<li> <strong>\u8b66\u544a<\/strong>\uff1a\u975e\u5173\u952e\u95ee\u9898\uff0c\u4f8b\u5982\u5df2\u5f03\u7528\u7684 api\u3002<\/li>\n<li> <strong>\u4fe1\u606f<\/strong>\uff1a\u4e00\u822c\u5e94\u7528\u7a0b\u5e8f\u4fe1\u606f\uff0c\u4f8b\u5982\u670d\u52a1\u5668\u542f\u52a8\u6216\u5173\u95ed\u3002<\/li>\n<li> <strong>\u8c03\u8bd5<\/strong>\uff1a\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u6709\u7528\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\u53d8\u91cf\u503c\u3002<\/li>\n<\/ul>\n<h3> \u5728 winston \u4e2d\u914d\u7f6e\u65e5\u5fd7\u7ea7\u522b <\/h3>\n<pre>logger.level = \"debug\"; \/\/ sets the minimum log level to debug, capturing all messages.\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u751f\u4ea7\u4e2d\uff0c\u6700\u597d\u5c06\u65e5\u5fd7\u7ea7\u522b\u4fdd\u6301\u5728 info \u6216 warn \u4ee5\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u65e5\u5fd7\u6570\u636e\u3002<\/p>\n<h2> \u7ed3\u6784\u5316\u65e5\u5fd7\u8bb0\u5f55\u7684\u4e00\u81f4\u6027 <\/h2>\n<p>\u7ed3\u6784\u5316\u65e5\u5fd7\u8bb0\u5f55\u901a\u8fc7\u4fdd\u6301\u4e00\u81f4\u7684\u683c\u5f0f\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u8fc7\u6ee4\u548c\u5206\u6790\u65e5\u5fd7\u3002<\/p>\n<h3> \u5c06\u5143\u6570\u636e\u6dfb\u52a0\u5230\u65e5\u5fd7 <\/h3>\n<p>user_id \u6216 request_id \u7b49\u5143\u6570\u636e\u53ef\u4ee5\u5e2e\u52a9\u8ddf\u8e2a\u65e5\u5fd7\u4e2d\u7684\u7279\u5b9a\u64cd\u4f5c\uff1a<\/p>\n<pre>logger.info(\"user login successful\", { user_id: \"12345\" });\nlogger.error(\"failed to fetch user data\", { user_id: \"12345\", error: \"database unavailable\" });\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h2> \u4e0e elasticsearch \u96c6\u6210\u4ee5\u5b9e\u73b0\u96c6\u4e2d\u65e5\u5fd7\u8bb0\u5f55 <\/h2>\n<p>elasticsearch \u5e7f\u6cdb\u7528\u4e8e\u96c6\u4e2d\u5f0f\u65e5\u5fd7\u7ba1\u7406\u548c\u641c\u7d22\u529f\u80fd\u3002<\/p>\n<ol>\n<li> <strong>\u5b89\u88c5 elasticsearch \u548c elasticsearch transport<\/strong> <\/li>\n<\/ol>\n<pre>   npm install @elastic\/elasticsearch winston-elasticsearch\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li> <strong>\u914d\u7f6e elasticsearch \u4f20\u8f93<\/strong> <\/li>\n<\/ol>\n<pre>   const { elasticsearchtransport } = require(\"winston-elasticsearch\");\n\n   const estransport = new elasticsearchtransport({\n       clientopts: { node: \"http:\/\/localhost:9200\" }\n   });\n\n   logger.add(estransport);\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u8bbe\u7f6e\u4f1a\u5c06\u65e5\u5fd7\u53d1\u9001\u5230 elasticsearch\uff0c\u5141\u8bb8\u60a8\u4f7f\u7528 kibana \u8fdb\u884c\u5b9e\u65f6\u65e5\u5fd7\u641c\u7d22\u548c\u5206\u6790\u3002<\/p>\n<h2> \u4f7f\u7528 prometheus \u548c grafana \u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u6307\u6807 <\/h2>\n<p>\u76d1\u63a7\u8ddf\u8e2a cpu \u4f7f\u7528\u7387\u3001\u5185\u5b58\u548c\u54cd\u5e94\u65f6\u95f4\u7b49\u5e94\u7528\u7a0b\u5e8f\u6027\u80fd\u6307\u6807\uff0c\u6709\u52a9\u4e8e\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u7a33\u5b9a\u3002<\/p>\n<h3> \u4f7f\u7528 node.js \u8bbe\u7f6e prometheus <\/h3>\n<ol>\n<li> <strong>\u5b89\u88c5 prometheus \u5ba2\u6237\u7aef\u5e93<\/strong> <\/li>\n<\/ol>\n<pre>   npm install prom-client\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li> <strong>\u521b\u5efa\u548c\u5bfc\u51fa\u6307\u6807<\/strong> <\/li>\n<\/ol>\n<pre>   const client = require(\"prom-client\");\n   const httprequestduration = new client.histogram({\n       name: \"http_request_duration_seconds\",\n       help: \"duration of http requests in seconds\",\n       labelnames: [\"method\", \"route\"]\n   });\n\n   function startmonitoring(req, res, next) {\n       const end = httprequestduration.starttimer();\n       res.on(\"finish\", () =&gt; end({ method: req.method, route: req.path }));\n       next();\n   }\n   app.use(startmonitoring);\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li> <strong>\u516c\u5f00\u6307\u6807\u7aef\u70b9<\/strong> <\/li>\n<\/ol>\n<pre>   app.get(\"\/metrics\", async (req, res) =&gt; {\n       res.set(\"Content-Type\", client.register.contentType);\n       res.end(await client.register.metrics());\n   });\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3> \u4f7f\u7528 grafana \u8fdb\u884c\u53ef\u89c6\u5316 <\/h3>\n<p>grafana \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u6839\u636e prometheus \u6307\u6807\u521b\u5efa\u4eea\u8868\u677f\u3002\u5c06 prometheus \u4f5c\u4e3a grafana \u4e2d\u7684\u6570\u636e\u6e90\u96c6\u6210\uff0c\u7136\u540e\u53ef\u89c6\u5316\u54cd\u5e94\u65f6\u95f4\u548c\u9519\u8bef\u7387\u7b49\u6307\u6807\u3002<\/p>\n<h2> \u73b0\u5b9e\u4e16\u754c\u7528\u4f8b\uff1a\u7535\u5b50\u5546\u52a1\u4e2d\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7 <\/h2>\n<p>\u8003\u8651\u4e00\u4e2a\u7535\u5b50\u5546\u52a1\u5e73\u53f0\uff0c\u5176\u4e2d\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\u5bf9\u4e8e\u4fdd\u6301\u9ad8\u6027\u80fd\u548c\u53ef\u9760\u6027\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<ol>\n<li> <strong>\u8bb0\u5f55\u6240\u6709\u4ea4\u6613<\/strong>\uff1a\u4f7f\u7528\u7ed3\u6784\u5316\u65e5\u5fd7\u6355\u83b7\u8ba2\u5355\u548c\u4ed8\u6b3e\u4e8b\u4ef6\uff0c\u5305\u62ec order_id \u548c user_id \u7b49\u5143\u6570\u636e\u3002<\/li>\n<li> <strong>\u9519\u8bef\u8ddf\u8e2a<\/strong>\uff1a\u4f7f\u7528 winston \u8bb0\u5f55\u4ed8\u6b3e\u5931\u8d25\u7b49\u9519\u8bef\uff0c\u4ee5\u53ca\u5806\u6808\u8ddf\u8e2a\u548c\u5143\u6570\u636e\u4ee5\u52a0\u5feb\u8c03\u8bd5\u901f\u5ea6\u3002<\/li>\n<li> <strong>\u76d1\u63a7\u670d\u52a1\u5668\u8fd0\u884c\u72b6\u51b5<\/strong>\uff1a\u8bbe\u7f6e prometheus \u6765\u76d1\u63a7\u54cd\u5e94\u65f6\u95f4\u548c\u8bf7\u6c42\u8ba1\u6570\uff0c\u5e76\u5728 grafana \u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u4ee5\u83b7\u53d6\u5b9e\u65f6\u89c1\u89e3\u3002<\/li>\n<li> <strong>\u8bbe\u7f6e\u8b66\u62a5<\/strong>\uff1a\u6839\u636e\u6307\u6807\u914d\u7f6e\u8b66\u62a5\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8bf7\u6c42\u6301\u7eed\u65f6\u95f4\u8d85\u8fc7\u9608\u503c\uff0c\u5219\u5411\u7ba1\u7406\u5458\u53d1\u9001\u8b66\u62a5\u3002<\/li>\n<\/ol>\n<p>\u6b64\u8bbe\u7f6e\u63d0\u4f9b\u4e86\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u72b6\u51b5\u7684\u5168\u9762\u89c6\u56fe\uff0c\u5141\u8bb8\u4e3b\u52a8\u68c0\u6d4b\u548c\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<h2> \u7ed3\u8bba <\/h2>\n<p>\u5728 node.js \u4e2d\u5b9e\u73b0\u5f3a\u5927\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\u5bf9\u4e8e\u7ef4\u62a4\u53ef\u9760\u6027\u548c\u786e\u4fdd\u5feb\u901f\u6545\u969c\u6392\u9664\u81f3\u5173\u91cd\u8981\u3002\u4f7f\u7528 winston\u3001elasticsearch\u3001prometheus \u548c grafana \u7b49\u5de5\u5177\uff0c\u60a8\u53ef\u4ee5\u6355\u83b7\u7ed3\u6784\u5316\u65e5\u5fd7\u3001\u96c6\u4e2d\u65e5\u5fd7\u5e76\u6709\u6548\u76d1\u63a7\u5173\u952e\u6027\u80fd\u6307\u6807\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fNodejs \u4e2d\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\uff1a\u6700\u4f73\u5b9e\u8df5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u6548\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\u5bf9\u4e8e\u7ef4\u62a4\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u72b6\u51b5\u3001\u5feb\u901f\u8bc6\u522b\u95ee\u9898\u548c\u63d0\u9ad8\u6027\u80fd\u81f3\u5173\u91cd\u8981\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8 node.js \u5e94\u7528\u7a0b\u5e8f\u7684\u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\uff0c\u6db5\u76d6\u9009\u62e9\u65e5\u5fd7\u8bb0\u5f55\u7ea7\u522b\u3001\u8bbe\u7f6e\u7ed3\u6784\u5316\u65e5\u5fd7\u3001\u4e0e\u76d1\u63a7\u5de5\u5177\u96c6\u6210\u4ee5\u53ca\u4f7f\u7528 winston \u548c elasticsearch \u7684\u6700\u4f73\u5b9e\u8df5\u7b49\u5173\u952e\u4e3b\u9898\u3002 \u65e5\u5fd7\u8bb0\u5f55\u548c\u76d1\u63a7\u7b80\u4ecb \u65e5\u5fd7\u8bb0\u5f55\u6709\u52a9\u4e8e\u6355\u83b7\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u5b9e\u65f6\u4e8b\u4ef6\u3001\u9519\u8bef\u548c\u5176\u4ed6\u91cd\u8981\u4fe1\u606f\uff0c\u800c\u76d1\u63a7\u5219\u6d89\u53ca\u8ddf\u8e2a\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u5e94\u7528\u7a0b\u5e8f\u6027\u80fd\u6307\u6807\u3002\u5b83\u4eec\u5171\u540c\u63d0\u4f9b\u4e86\u6709\u5173\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u72b6\u51b5\u7684\u91cd\u8981\u89c1\u89e3\uff0c\u4ece\u800c\u80fd\u591f\u4e3b\u52a8\u89e3\u51b3\u95ee\u9898\u3002 \u5728 node.js \u4e2d\u8bbe\u7f6e\u57fa\u672c\u65e5\u5fd7\u8bb0\u5f55 \u5185\u7f6e\u7684\u63a7\u5236\u53f0\u5bf9\u8c61\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\uff0c\u4f46\u4e13\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5e93\u5bf9\u4e8e\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f\u6765\u8bf4\u66f4\u52a0\u5f3a\u5927\u3002 \u57fa\u672c\u63a7\u5236\u53f0\u65e5\u5fd7\u8bb0\u5f55 console.log(&#8220;server started on port 3000&#8221;); console.warn(&#8220;this is a warning&#8221;); console.error(&#8220;error occurred while processing request&#8221;); \u767b\u5f55\u540e\u590d\u5236 \u4f46\u662f\uff0c\u63a7\u5236\u53f0\u65e5\u5fd7\u8bb0\u5f55\u5728\u590d\u6742\u5e94\u7528\u4e2d\u5b58\u5728\u5c40\u9650\u6027\uff0c\u4f8b\u5982\u7f3a\u4e4f\u65e5\u5fd7\u7ea7\u522b\u63a7\u5236\u4ee5\u53ca\u6ca1\u6709\u65e5\u5fd7\u6301\u4e45\u5316\u3002 \u6e29\u65af\u987f\u4ecb\u7ecd winston \u662f\u4e00\u4e2a\u6d41\u884c\u7684 node.js \u65e5\u5fd7\u5e93\uff0c\u63d0\u4f9b\u591a\u4e2a\u65e5\u5fd7\u7ea7\u522b\u3001\u4f20\u8f93\uff08\u65e5\u5fd7\u76ee\u7684\u5730\uff09\u548c\u7ed3\u6784\u5316\u65e5\u5fd7\u8bb0\u5f55\u3002 \u5b89\u88c5\u6e29\u65af\u987f\uff1a npm install winston \u767b\u5f55\u540e\u590d\u5236 \u8bbe\u7f6e\u6e29\u65af\u987f const winston = require(&#8220;winston&#8221;); \/\/ configure logger const logger = winston.createlogger({ level: &#8220;info&#8221;, format: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2916","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2916"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2916\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}