|
8 | 8 | -module(rabbit_mgmt_format).
|
9 | 9 |
|
10 | 10 | -export([format/2, ip/1, ipb/1, amqp_table/1, tuple/1]).
|
11 |
| --export([parameter/1, now_to_str/1, now_to_str_ms/1, strip_pids/1]). |
| 11 | +-export([parameter/1, now_to_str/0, now_to_str/1, strip_pids/1]). |
12 | 12 | -export([protocol/1, resource/1, queue/1, queue_state/1, queue_info/1]).
|
13 | 13 | -export([exchange/1, user/1, internal_user/1, binding/1, url/2]).
|
14 | 14 | -export([pack_binding_props/2, tokenise/1]).
|
@@ -187,20 +187,16 @@ protocol_version({Major, Minor}) -> io_lib:format("~B-~B", [Major, Min
|
187 | 187 | protocol_version({Major, Minor, 0}) -> protocol_version({Major, Minor});
|
188 | 188 | protocol_version({Major, Minor, Revision}) -> io_lib:format("~B-~B-~B",
|
189 | 189 | [Major, Minor, Revision]).
|
| 190 | +% Note: |
| 191 | +% Uses the same format as the OTP logger: |
| 192 | +% https://github.com/erlang/otp/blob/82e74303e715c7c64c1998bf034b12a48ce814b1/lib/kernel/src/logger_formatter.erl#L306-L311 |
| 193 | +now_to_str() -> |
| 194 | + calendar:system_time_to_rfc3339(os:system_time(millisecond), [{unit, millisecond}]). |
190 | 195 |
|
191 | 196 | now_to_str(unknown) ->
|
192 | 197 | unknown;
|
193 |
| -now_to_str(MilliSeconds) -> |
194 |
| - BaseDate = calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, |
195 |
| - {0, 0, 0}}), |
196 |
| - Seconds = BaseDate + (MilliSeconds div 1000), |
197 |
| - {{Y, M, D}, {H, Min, S}} = calendar:gregorian_seconds_to_datetime(Seconds), |
198 |
| - print("~w-~2.2.0w-~2.2.0w ~w:~2.2.0w:~2.2.0w", [Y, M, D, H, Min, S]). |
199 |
| - |
200 |
| -now_to_str_ms(unknown) -> |
201 |
| - unknown; |
202 |
| -now_to_str_ms(MilliSeconds) -> |
203 |
| - print("~s:~3.3.0w", [now_to_str(MilliSeconds), MilliSeconds rem 1000]). |
| 198 | +now_to_str(MilliSeconds) when is_integer(MilliSeconds) -> |
| 199 | + calendar:system_time_to_rfc3339(MilliSeconds, [{unit, millisecond}]). |
204 | 200 |
|
205 | 201 | resource(unknown) -> unknown;
|
206 | 202 | resource(Res) -> resource(name, Res).
|
|
0 commit comments