@@ -284,13 +284,26 @@ VarnishLog.Dispatch
284284Prototype
285285 ::
286286
287- Dispatch(cb, priv = None)
287+ Dispatch(cb=None , priv=None, maxread=1, vxidcb=None, groupcb= None)
288288
289289Parameter
290290 ::
291291
292- FUNC cb callback function
293- OBJECT priv
292+ FUNC cb callback function per line
293+ OBJECT priv
294+ INT maxread Maximum number of reads, if have unread log in VSL.(0=infinity)
295+ FUNC vxidcb callback function per vxid(call per line, if group option set to raw)
296+ FUNC groupcb callback function per group(raw, vxid, request, session)
297+
298+
299+ ===================== ======== ======== =========== ===========
300+ callbacktype \\ group raw vxid request session
301+ ===================== ======== ======== =========== ===========
302+ cb per line per line per line per line
303+ vxidcb per line per vxid per vxid per vxid
304+ groupcb per line per vxid per request per session
305+ ===================== ======== ======== =========== ===========
306+
294307
295308Return value
296309 ::
@@ -306,20 +319,42 @@ Description
306319Example
307320 ::
308321
309- def cb(vap,cbd,priv):
310- #output
311- #...
312- #{'level': 0L, 'type': 'c', 'reason': 0, 'vxid_parent': 0, 'length': 22L, 'tag': 26L, 'vxid': 65709, 'data': 'Vary: Accept-Encoding\x00', 'isbin': 0L}
313- #{'level': 0L, 'type': 'c', 'reason': 0, 'vxid_parent': 0, 'length': 23L, 'tag': 26L, 'vxid': 65709, 'data': 'Content-Encoding: gzip\x00', 'isbin': 0L}
314- #...
322+ def cbline(vap, cbd, priv):
315323 print cbd
316-
317- vsl = varnishapi.VarnishLog(['-c'])
324+ def cbvxid(vap, priv):
325+ print "VXID"
326+ def cbgroup(vap, priv):
327+ print "GROUP"
328+
329+ vsl = varnishapi.VarnishLog(['-g','request'])
330+ arg = {
331+ 'cb' : cbline,
332+ 'vxidcb' : cbvxid,
333+ 'groupcb' : cbgroup,
334+ 'maxread' : 0,
335+ }
318336 while 1:
319- ret = vsl.Dispatch(cb )
337+ ret = vsl.Dispatch(**arg )
320338 if 0 == ret:
321339 time.sleep(0.5)
322340 vsl.Fini()
341+ #output
342+ #
343+ # {'level': 1L, 'data': u'req 32907 rxreq', 'length': 16L, 'transaction_type': 2, 'reason': 2, 'tag': 76L, 'vxid': 32908, 'vxid_parent': 0, 'type': 'c', 'isbin': 0L}
344+ # {'level': 1L, 'data': u'Start: 1509598791.285514 0.000000 0.000000', 'length': 43L, 'transaction_type': 2, 'reason': 2, 'tag': 80L, 'vxid': 32908, 'vxid_parent': 0, 'type': 'c', 'isbin': 0L}
345+ # {'level': 1L, 'data': u'Req: 1509598791.285514 0.000000 0.000000', 'length': 41L, 'transaction_type': 2, 'reason': 2, 'tag': 80L, 'vxid': 32908, 'vxid_parent': 0, 'type': 'c', 'isbin': 0L}
346+ # ...
347+ # {'level': 1L, 'data': u'', 'length': 1L, 'transaction_type': 2, 'reason': 2, 'tag': 77L, 'vxid': 32908, 'vxid_parent': 0, 'type': 'c', 'isbin': 0L}
348+ # VXID
349+ # {'level': 2L, 'data': u'bereq 32908 fetch', 'length': 18L, 'transaction_type': 3, 'reason': 6, 'tag': 76L, 'vxid': 32909, 'vxid_parent': 32908, 'type': 'b', 'isbin': 0L}
350+ # ...
351+ # {'level': 2L, 'data': u'165 0 165 160 298 458', 'length': 22L, 'transaction_type': 3, 'reason': 6, 'tag': 83L, 'vxid': 32909, 'vxid_parent': 32908, 'type': 'b', 'isbin': 0L}
352+ # {'level': 2L, 'data': u'', 'length': 1L, 'transaction_type': 3, 'reason': 6, 'tag': 77L, 'vxid': 32909, 'vxid_parent': 32908, 'type': 'b', 'isbin': 0L}
353+ # VXID
354+ # GROUP
355+ # {'level': 1L, 'data': u'req 65648 rxreq', 'length': 16L, 'transaction_type': 2, 'reason': 2, 'tag': 76L, 'vxid': 65649, 'vxid_parent': 0, 'type': 'c', 'isbin': 0L}
356+ # {'level': 1L, 'data': u'Start: 1509598842.452101 0.000000 0.000000', 'length': 43L, 'transaction_type': 2, 'reason': 2, 'tag': 80L, 'vxid': 65649, 'vxid_parent': 0, 'type': 'c', 'isbin': 0L}
357+
323358
324359
325360VarnishLog.VSL_tags / VSL_tags_rev
@@ -404,6 +439,8 @@ Description
404439
405440HISTORY
406441===========
442+ trunk: Enhance perfomance. add some feature in dispatch(). add transaction_type in callbackdata(cbd)
443+
407444Version 52.22: Fix VSC/varnishstat bug.(fix declare, add fini(I mis-deleted...) p-r #71,72 thanks ehocdet). Fix key varnishstat's decode for python3.
408445
409446Version 52.21: Initial support Varnish5.2.x
0 commit comments