是否有Meteor包可以让我这样做?
或者,有没有办法使用像global-request-logger这样的节点包来记录Meteor应用程序的出站http流量?
答案 0 :(得分:7)
是的,您可以在Meteor应用程序中使用npm模块。
以下是包含它们的一种方法:
meteor add meteorhacks:npm
。packages.json
文件。{ "global-request-logger": "0.0.1" }
文件中插入packages.json
,列出对所需npm模块global-request-logger
的依赖关系。if (Meteor.isServer) {
var globalLog = Meteor.npmRequire('global-request-logger');
globalLog.initialize();
}
请注意,大多数npm模块都提供带有回调的异步API。遗憾的是,您无法在Meteor应用程序中直接使用它们。但是,您可以使用异步实用程序来桥接同步Meteor API和异步npm模块之间的空白。
详细了解meteorhacks:async
的{{3}}。
还有一个可用的Meteor包,用于记录HTTP请求。该包名为meteor-log-requests
,由async utilities提供。目前该包未发布,因此如果您想使用它,则需要将其安装为本地包。
以下是:
meteor-log-requests
Evented Mind。packages
目录。meteor-log-requests
目录中的packages
包。meteor add log-requests
添加包。日志输出如下所示:
I20150730-07:40:28.627(2) (log_requests.js:11) 127.0.0.1: GET /
I20150730-07:40:28.795(2) (log_requests.js:11) 127.0.0.1: GET /20ae2c8d51b2507244e598844414ecdec2615ce3.css
I20150730-07:40:28.800(2) (log_requests.js:11) 127.0.0.1: GET /packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18
I20150730-07:40:28.812(2) (log_requests.js:11) 127.0.0.1: GET /packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf
I20150730-07:40:28.848(2) (log_requests.js:11) 127.0.0.1: GET /packages/json.js?e22856eae714c681199eabc5c0710b904b125554
I20150730-07:40:28.852(2) (log_requests.js:11) 127.0.0.1: GET /packages/base64.js?1a63019243b73298e2964e6d4680f25bca657726
I20150730-07:40:28.857(2) (log_requests.js:11) 127.0.0.1: GET /packages/ejson.js?71047b64b5196348bdbe5fd5eea9ac97a5a9eb14
I20150730-07:40:28.946(2) (log_requests.js:11) 127.0.0.1: GET /packages/logging.js?07e201b648f16be8435a4f666156995eeda0c750
I20150730-07:40:28.966(2) (log_requests.js:11) 127.0.0.1: GET /packages/reload.js?da8974b7231dd8c0caccb5f322dcf97329d486d1
I20150730-07:40:28.970(2) (log_requests.js:11) 127.0.0.1: GET /packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c
I20150730-07:40:28.986(2) (log_requests.js:11) 127.0.0.1: GET /packages/random.js?fe7b46080c91ce482acf6fc326afbc5b176f0502
I20150730-07:40:28.991(2) (log_requests.js:11) 127.0.0.1: GET /packages/retry.js?1f1dd2c35d300110fdaba51ce4473583bc3bf031
I20150730-07:40:28.997(2) (log_requests.js:11) 127.0.0.1: GET /packages/check.js?ac81167b8513b85b926c167bba423981b0c4cf9c
I20150730-07:40:29.049(2) (log_requests.js:11) 127.0.0.1: GET /packages/id-map.js?9ea6eaae8d74693ce2505a858d9a5e60cf191298
I20150730-07:40:29.071(2) (log_requests.js:11) 127.0.0.1: GET /packages/ordered-dict.js?bf8af2f26c8d96bf8b2e6b407d3ed69f23c2cd37
I20150730-07:40:29.087(2) (log_requests.js:11) 127.0.0.1: GET /packages/geojson-utils.js?81b79d5cf96d00b4b7a28987debcffb665c17526
I20150730-07:40:29.102(2) (log_requests.js:11) 127.0.0.1: GET /packages/minimongo.js?af9eb9d7447544ca9b839a3dcf7ed2da2209b56c
I20150730-07:40:29.109(2) (log_requests.js:11) 127.0.0.1: GET /packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706
I20150730-07:40:29.115(2) (log_requests.js:11) 127.0.0.1: GET /packages/insecure.js?3dc9d4a2dad55999b5b15a447d57f3d5fb66b290
I20150730-07:40:29.170(2) (log_requests.js:11) 127.0.0.1: GET /packages/mongo.js?3cfe0c5981c197df33036a37574850f057e934a6
I20150730-07:40:29.182(2) (log_requests.js:11) 127.0.0.1: GET /packages/autoupdate.js?9a5ea03bf057815385bf569c7acc2c285c005491
I20150730-07:40:29.195(2) (log_requests.js:11) 127.0.0.1: GET /packages/meteor-platform.js?499a2f8522e25820b1153c69a92751ccaae507b3
I20150730-07:40:29.200(2) (log_requests.js:11) 127.0.0.1: GET /packages/autopublish.js?c3059a78bb200b171099fc4fa1a9345101790ddb
I20150730-07:40:29.264(2) (log_requests.js:11) 127.0.0.1: GET /packages/log-requests.js?b9d6c721fd5a35edc5998a3296966595fe398910
I20150730-07:40:29.286(2) (log_requests.js:11) 127.0.0.1: GET /packages/jquery.js?dd8bac56f8fd3666d433d2285ae01e52597cc51a
I20150730-07:40:29.301(2) (log_requests.js:11) 127.0.0.1: GET /packages/meteorhacks_npm.js?604e35d5437f43224cde2c1f9e5e9aace95a9a95
I20150730-07:40:29.304(2) (log_requests.js:11) 127.0.0.1: GET /packages/npm-container.js?c4195e22b5a0a7239a415a3d95b3b702c34fa28d
I20150730-07:40:29.315(2) (log_requests.js:11) 127.0.0.1: GET /packages/webapp.js?e1be090051b82f046484dccc2de7d747e50c7328
I20150730-07:40:29.334(2) (log_requests.js:11) 127.0.0.1: GET /packages/deps.js?504589e1e9585dec8f9f6094e5a87b22de3783a1
I20150730-07:40:29.453(2) (log_requests.js:11) 127.0.0.1: GET /packages/reactive-dict.js?1cb61826ceb23464171f17c2191c7e04a9b91508
I20150730-07:40:29.466(2) (log_requests.js:11) 127.0.0.1: GET /packages/session.js?daf192a7244079d45db32a6fc26ebc3881fc1aa3
I20150730-07:40:29.469(2) (log_requests.js:11) 127.0.0.1: GET /packages/livedata.js?718526445deb4d9baacb6d92c551adea1d36c1e1
I20150730-07:40:29.473(2) (log_requests.js:11) 127.0.0.1: GET /packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2
I20150730-07:40:29.476(2) (log_requests.js:11) 127.0.0.1: GET /packages/observe-sequence.js?0532a9dd76dd78f543eb4d79a1e429df186d8bde
I20150730-07:40:29.482(2) (log_requests.js:11) 127.0.0.1: GET /packages/reactive-var.js?20335b7b37165980ddd9f23943b2e5b00aae1cc2
I20150730-07:40:29.553(2) (log_requests.js:11) 127.0.0.1: GET /packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51
I20150730-07:40:29.577(2) (log_requests.js:11) 127.0.0.1: GET /packages/ui.js?5a663333fd30f8fd913f110e0ef779e84f67c4b8
I20150730-07:40:29.586(2) (log_requests.js:11) 127.0.0.1: GET /packages/templating.js?376767bb0d2463b3b2615a1b90e77f6b22d39d7b
I20150730-07:40:29.588(2) (log_requests.js:11) 127.0.0.1: GET /packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f
I20150730-07:40:29.594(2) (log_requests.js:11) 127.0.0.1: GET /packages/launch-screen.js?495e58cf2465ba553324c68301cc62076b1fda1e
I20150730-07:40:29.601(2) (log_requests.js:11) 127.0.0.1: GET /packages/meteorhacks_async.js?e687b9e863dc811fb3f313d1c6f237c7a2b1924b
I20150730-07:40:29.662(2) (log_requests.js:11) 127.0.0.1: GET /packages/global-imports.js?28b039ee71a940b59e6694e1b2c8c7555daafc2d
I20150730-07:40:29.669(2) (log_requests.js:11) 127.0.0.1: GET /template.meteor-log.js?a9c3a806e3371cc14c0e8d6f86b73b7bf2ef19d7
I20150730-07:40:29.675(2) (log_requests.js:11) 127.0.0.1: GET /meteor-log.js?a4f638a50228714016abbc604c243f65b057e771
您可能还想记录GitHub repository消息,因为DDP是用于客户端和服务器之间通信的协议(涉及出版物,MongoDB操作和流星方法)。要记录DDP消息,您可以使用DDP:
sudo npm install -g ddp-analyzer
。ddp-analyzer-proxy
启动DDP Analyzer Proxy。export DDP_DEFAULT_CONNECTION_URL=http://localhost:3030
设置DDP默认连接。meteor
启动您的应用。 ddp-analyzer-proxy
将在您的终端中转储日志: