Skip to content

Commit dfa991f

Browse files
seriypsCopilot
andcommitted
docs: add cross-references to migration-flow.md and debug logging tip
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 492956a commit dfa991f

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,32 @@ Workflow:
199199
- All configuration options are documented in `src/mtproto_proxy.app.src`.
200200
- Config can be reloaded without restart: `make update-sysconfig && systemctl reload mtproto-proxy`.
201201

202+
## Debugging
203+
204+
### Enabling debug logs for a single module at runtime
205+
206+
The primary log level is `info`. To see `?LOG_DEBUG` messages from one module without
207+
flooding the log with debug output from all of OTP:
208+
209+
```erlang
210+
% In the running Erlang shell (e.g. via: sudo /opt/personal_mtproxy/bin/mtproto_proxy remote_console)
211+
logger:set_module_level(mtp_handler, debug). % override primary gate for this module only
212+
logger:set_handler_config(default, level, debug). % let the file handler pass debug through
213+
```
214+
215+
This works because `set_module_level` bypasses the primary level check *only* for the
216+
named module — no other module's debug messages are affected. The handler level change
217+
is required because the `default` file handler has its own `level => info` guard.
218+
219+
To revert:
220+
221+
```erlang
222+
logger:unset_module_level(mtp_handler).
223+
logger:set_handler_config(default, level, info).
224+
```
225+
226+
Both settings are in-memory only and reset on restart.
227+
202228
## Security Considerations
203229

204230
- Do **not** commit real secrets, tags, or credentials into config files.

src/mtp_down_conn.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ handle_info({tcp_closed, Sock}, #state{sock = Sock, upstreams = Ups, pool = Pool
171171
0 ->
172172
{stop, {shutdown, downstream_socket_closed}, State};
173173
N ->
174+
%% See ../doc/migration-flow.md
174175
%% Remove self from pool first so no new upstreams can be assigned.
175176
ok = mtp_dc_pool:downstream_closing(Pool, self()),
176177
?LOG_INFO("Downstream socket closed with ~p active client(s); migrating", [N]),

src/mtp_handler.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ keys_str() ->
8080
send(Upstream, Packet) ->
8181
gen_server:cast(Upstream, Packet).
8282

83+
%% See doc/migration-flow.md
8384
-spec migrate(pid(), OldDown :: mtp_down_conn:handle()) -> ok.
8485
migrate(Upstream, OldDown) ->
8586
gen_server:cast(Upstream, {migrate, OldDown}).

0 commit comments

Comments
 (0)