上次讲了onCreate、 OnDelete等钩子或者事自定义。今天来讲一下,如果想要知道什么时候同步完毕,或者同步完毕时候进行日志记录,那么怎么办呢?

研究一番发现collect函数是在同步结束后调用的,我们可以重新collect来进行同步完毕后的日志记录

来验证一下echoCollect在什么时间调用,以及会不会在sleep 10秒输出xxxxxx之后调用并输出日志


启动,并在监控目录创建一个文件,看日志输出
1.onStartup同步执行完毕后,会触发一次collect函数调用, 触发事件类型为Init
2.onCreate同步成功之后,触发了collect函数调用,触发事件类型为Create
从第二个输出我们可以看到,collect并不是在onCreate或者onStartup函数执行完毕后调用的,而是在相对于的同步事件执行数据同步成功之后才去调用。比如,onCreate,直到sleep 10秒,输出xxxxxxx之后才输出了同步成功日志。
在echoCollect中,我们使用了agent.etype,agent指的是当前同步操作的事件,etype是事件类型,是事件内置的属性之一,事件还内置了很多属性。

研究一番发现collect函数是在同步结束后调用的,我们可以重新collect来进行同步完毕后的日志记录

来验证一下echoCollect在什么时间调用,以及会不会在sleep 10秒输出xxxxxx之后调用并输出日志


启动,并在监控目录创建一个文件,看日志输出
1.onStartup同步执行完毕后,会触发一次collect函数调用, 触发事件类型为Init
2.onCreate同步成功之后,触发了collect函数调用,触发事件类型为Create
从第二个输出我们可以看到,collect并不是在onCreate或者onStartup函数执行完毕后调用的,而是在相对于的同步事件执行数据同步成功之后才去调用。比如,onCreate,直到sleep 10秒,输出xxxxxxx之后才输出了同步成功日志。
在echoCollect中,我们使用了agent.etype,agent指的是当前同步操作的事件,etype是事件类型,是事件内置的属性之一,事件还内置了很多属性。