简体   繁体   English

nodejs浏览器同步-日志记录

[英]nodejs browser-sync - logging

im very new to nodejs but was wondering if the following was easily possible to achieve. 对于nodejs来说,我是一个非常新的人,但是想知道是否可以轻松实现以下目标。

I use Gulp along with browser-sync plugin. 我将Gulp与浏览器同步插件一起使用。 I was wondering if there was a way to log every time the browser gets re-injected with the domain and time over a port range. 我想知道是否有一种方法可以使浏览器每次在端口范围内重新注入域和时间。 The reason for this being I want to be able to plot productivity over projects without having to manually record this and this seems to be the most logical solution. 原因是我希望能够在不手动记录的情况下绘制项目的生产率,这似乎是最合乎逻辑的解决方案。

Is there anything out there like this or could this easily be added into a Gulp file? 是否有类似的东西,或者可以轻松地将其添加到Gulp文件中?

Many thanks, Luke 非常感谢,卢克

There are some options and you can use the emitter to react to events like stream:changed, browser:reload, client:connected, connection,... 有一些选项,您可以使用发射器来响应诸如stream:changed,浏览器:reload,client:connected,connection等事件。

example: 例:

var bs = require("browser-sync").create();
bs.init({}); //http://www.browsersync.io/docs/options/
....
bs.emitter.on("file:reload", function(){
console.log("File reload - Details:"+arguments)
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM