[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] Improving the note_netsync_* hooks for logging
From: |
Richard Levitte - VMS Whacker |
Subject: |
Re: [Monotone-devel] Improving the note_netsync_* hooks for logging |
Date: |
Wed, 25 Oct 2006 00:39:16 +0200 (CEST) |
Just wanted to let you know that I have no problem with that change.
Actually, some of the new parameters would make certain things easier
for me :-).
In message <address@hidden> on Tue, 24 Oct 2006 15:16:23 -0500, Timothy
Brownawell <address@hidden> said:
tbrownaw> There's a new branch nvm.tbrownaw.netsync-note-hooks that
tbrownaw> changes the note_netsync_* hooks slightly, as well as some
tbrownaw> supporting changes in netsync.cc .
tbrownaw>
tbrownaw> The most noticable change to the hooks is that
tbrownaw> note_netsync_start is now called at the beginning of the
tbrownaw> connection, and that note_netsync_start and note_netsync_end
tbrownaw> are called even if nothing was transferred.
tbrownaw>
tbrownaw> The most visible supporting change is that session::error()
tbrownaw> takes a new argument, for a numeric error code. This is
tbrownaw> saved, and also stringified and prepended to the error
tbrownaw> netcmd, and (if present) is decoded on the other side and
tbrownaw> saved there as well. This does not break compatibility;
tbrownaw> older clients will just see a 3-digit error code at the
tbrownaw> beginning of any errors received.
tbrownaw>
tbrownaw> The reason for this is that the error code is passed to the
tbrownaw> note_netsync_end hook, so it can differentiate between
tbrownaw> successful connections, interrupted connections, connections
tbrownaw> that failed due to permissions, or connections that failed
tbrownaw> some other way.
tbrownaw>
tbrownaw>
tbrownaw> Are there objections to doing this? Is this general way of doing it
tbrownaw> sane, or should it be done differently?
tbrownaw>
tbrownaw>
tbrownaw>
tbrownaw> Currently it uses these, somewhat based on the HTTP codes:
tbrownaw> const static int no_error = 200;
tbrownaw> const static int bad_request = 400;
tbrownaw> const static int protocol_error = 401;
tbrownaw> const static int permission_error = 403;
tbrownaw> //const static int other_error = 500;
tbrownaw> const static int connection_broken = 504;
tbrownaw>
tbrownaw>
tbrownaw> At the end of this mail are some sample hooks that will print lines
like
tbrownaw> this for the server:
tbrownaw>
tbrownaw> 127.0.0.1:36573 "address@hidden" [2006-10-24T14:33:42
tbrownaw> 2006-10-24T14:38:48] sync "*" "" 504 479397:12608180 0:9675 0:2412
0:31
tbrownaw>
tbrownaw> 127.0.0.1:42102 "address@hidden" [2006-10-24T14:38:51
tbrownaw> 2006-10-24T14:51:59] sync "*" "" 504 916978:21702890 0:15499 0:3849
0:31
tbrownaw>
tbrownaw> 127.0.0.1:56109 "address@hidden" [2006-10-24T14:52:04
tbrownaw> 2006-10-24T14:52:05] sync "*" "" 403 328:318 0:0 0:0 0:0
tbrownaw>
tbrownaw> 127.0.0.1:56110 "" [2006-10-24T14:52:14 2006-10-24T15:03:27] pull "*"
""
tbrownaw> 200 1165989:18334344 0:10878 0:2706 0:6
tbrownaw>
tbrownaw> 127.0.0.1:46195 "" [2006-10-24T15:05:11 2006-10-24T15:05:15] pull "*"
""
tbrownaw> 200 1794:1860 0:0 0:0 0:0
tbrownaw>
tbrownaw>
tbrownaw>
tbrownaw>
tbrownaw> function note_netsync_start(session_id, my_role, sync_type,
remote_host,
tbrownaw> remote_keyname, includes, excludes)
tbrownaw> if netsync_info == nil then netsync_info = {} end
tbrownaw> if sync_type == 1 then sync_type = "push"
tbrownaw> elseif sync_type == 2 then sync_type = "pull"
tbrownaw> elseif sync_type == 3 then sync_type = "sync" end
tbrownaw> netsync_info[session_id] =
tbrownaw> {
tbrownaw> includes = includes,
tbrownaw> excludes = excludes,
tbrownaw> host = remote_host,
tbrownaw> key = remote_keyname,
tbrownaw> branches = {},
tbrownaw> start_time = os.time(),
tbrownaw> my_role = my_role,
tbrownaw> type = sync_type
tbrownaw> }
tbrownaw> end
tbrownaw>
tbrownaw> function note_netsync_end(session_id, status,
tbrownaw> bytes_in, bytes_out,
tbrownaw> certs_in, certs_out,
tbrownaw> revs_in, revs_out,
tbrownaw> keys_in, keys_out)
tbrownaw> local tbl = netsync_info[session_id]
tbrownaw> local fmt = "%Y-%m-%dT%H:%M:%S"
tbrownaw>
tbrownaw> if tbl.my_role == "server" then
tbrownaw> local str = '%s "%s" [%s %s] %s "%s" "%s" %s %s:%s %s:%s %s:%s
%s:%s'
tbrownaw> str = string.format(str,
tbrownaw> tbl.host, tbl.key,
tbrownaw> os.date(fmt, tbl.start_time), os.date(fmt),
tbrownaw> tbl.type,
tbrownaw> tbl.includes, tbl.excludes,
tbrownaw> status,
tbrownaw> bytes_in, bytes_out,
tbrownaw> certs_in, certs_out,
tbrownaw> revs_in, revs_out,
tbrownaw> keys_in, keys_out)
tbrownaw> print(str)
tbrownaw> end
tbrownaw> netsync_info[session_id] = nil
tbrownaw> end
-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.
--
Richard Levitte address@hidden
http://richard.levitte.org/
"When I became a man I put away childish things, including
the fear of childishness and the desire to be very grown up."
-- C.S. Lewis