From 04e3bb9acf3f55029f3f13c60cc2664a994fd8d3 Mon Sep 17 00:00:00 2001 From: "Rob Swindell (in GitKraken)" <rob@synchro.net> Date: Thu, 16 Feb 2023 14:29:07 -0800 Subject: [PATCH] Report correct upload/download Kbytes in data/logs/<date>.log files After the move to 64-bit upload/download byte counts, these integers are different width than 'long' on 32-bit builds (e.g. Windows), so these numbers were wrong on all but 64-bit *nix builds. The change here also uses the cool byte_estimate_to_str() function so that large byte totals are not expressed in 'K' but rather 'M', 'G', 'T' etc. suffixes. The formatting is otherwise consistent with the pre-existing log line format save for the use of an uppercase suffix now. Before: @- 02:19p T: 12 R: 0 P: 0 E: 0 F: 0 U: 0k 0 D:420k 1 After: @- 02:07p T: 0 R: 0 P: 0 E: 0 F: 0 U: 0K 0 D:420K 1 Before: @- 02:23p T: 0 R: 0 P: 0 E: 0 F: 0 U: 0k 0 D:1359k 1 After: @- 02:26p T: 1 R: 0 P: 0 E: 0 F: 0 U: 0K 0 D:1.3M 1 This fixes issue #519. I'm glad to hear that sysops still use these log files! --- src/sbbs3/logout.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sbbs3/logout.cpp b/src/sbbs3/logout.cpp index fd6dd27e76..9e50bae665 100644 --- a/src/sbbs3/logout.cpp +++ b/src/sbbs3/logout.cpp @@ -134,13 +134,18 @@ void sbbs_t::logout() putuserstr(useron.number, USER_CURDIR, cfg.dir[usrdir[curlib][curdir[curlib]]]->code); hhmmtostr(&cfg,&tm,str); SAFECAT(str," "); - if(sys_status&SS_USERON) + if(sys_status&SS_USERON) { + char ulb[64]; + char dlb[64]; safe_snprintf(tmp,sizeof(tmp),"T:%3u R:%3lu P:%3lu E:%3lu F:%3lu " - "U:%3luk %lu D:%3luk %lu" + "U:%4s %lu D:%4s %lu" ,(uint)(now-logontime)/60,posts_read,logon_posts - ,logon_emails,logon_fbacks,logon_ulb/1024UL,logon_uls - ,logon_dlb/1024UL,logon_dls); - else + ,logon_emails,logon_fbacks + ,byte_estimate_to_str(logon_ulb, ulb, sizeof(ulb), 1024, /* precision: */logon_ulb > 1024*1024) + ,logon_uls + ,byte_estimate_to_str(logon_dlb, dlb, sizeof(dlb), 1024, /* precision: */logon_dlb > 1024*1204) + ,logon_dls); + } else SAFEPRINTF(tmp,"T:%3u sec",(uint)(now-answertime)); SAFECAT(str,tmp); SAFECAT(str,"\r\n"); -- GitLab