mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-10-20 21:04:15 -04:00
Adding a way for log-format numbers to become more human readable.
This commit is contained in:
1 parent
6437b817c0
commit
df7ec1cf42
3 files changed
+23
-5
No files matched your search
@@ -16,8 +16,10 @@ Changes since 3.0.4:
|
||||
control over what is output. Added an extra type of --progress output
|
||||
using --info=progress2.
|
||||
|
||||
- Output numbers in 3-digit groups by default (e.g. 1,234,567). (See the
|
||||
--human-readable option for a way to turn it off.)
|
||||
- Output numbers in 3-digit groups by default (e.g. 1,234,567). See the
|
||||
--human-readable option for a way to turn it off. See also the daemon's
|
||||
"log format" parameter for a modifier that can request digit-grouping or
|
||||
human-readable output in log escapes (including --out-format).
|
||||
|
||||
- Added a "T" (terabyte) category to the --human-readable size suffixes.
|
||||
|
||||
|
||||
@@ -493,12 +493,21 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
|
||||
buf[total] = '\0';
|
||||
|
||||
for (p = buf; (p = strchr(p, '%')) != NULL; ) {
|
||||
int humanize = 0;
|
||||
s = p++;
|
||||
c = fmt + 1;
|
||||
while (*p == '\'') {
|
||||
humanize++;
|
||||
p++;
|
||||
}
|
||||
if (*p == '-')
|
||||
*c++ = *p++;
|
||||
while (isDigit(p) && c - fmt < (int)(sizeof fmt) - 8)
|
||||
*c++ = *p++;
|
||||
while (*p == '\'') {
|
||||
humanize++;
|
||||
p++;
|
||||
}
|
||||
if (!*p)
|
||||
break;
|
||||
*c = '\0';
|
||||
@@ -522,7 +531,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
|
||||
case 'l':
|
||||
strlcat(fmt, "s", sizeof fmt);
|
||||
snprintf(buf2, sizeof buf2, fmt,
|
||||
comma_num(F_LENGTH(file)));
|
||||
do_big_num(F_LENGTH(file), humanize, NULL));
|
||||
n = buf2;
|
||||
break;
|
||||
case 'U':
|
||||
@@ -639,7 +648,8 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
|
||||
initial_stats->total_read;
|
||||
}
|
||||
strlcat(fmt, "s", sizeof fmt);
|
||||
snprintf(buf2, sizeof buf2, fmt, comma_num(b));
|
||||
snprintf(buf2, sizeof buf2, fmt,
|
||||
do_big_num(b, humanize, NULL));
|
||||
n = buf2;
|
||||
break;
|
||||
case 'c':
|
||||
@@ -651,7 +661,8 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
|
||||
initial_stats->total_read;
|
||||
}
|
||||
strlcat(fmt, "s", sizeof fmt);
|
||||
snprintf(buf2, sizeof buf2, fmt, comma_num(b));
|
||||
snprintf(buf2, sizeof buf2, fmt,
|
||||
do_big_num(b, humanize, NULL));
|
||||
n = buf2;
|
||||
break;
|
||||
case 'C':
|
||||
|
||||
@@ -524,6 +524,11 @@ The format is a text string containing embedded single-character escape
|
||||
sequences prefixed with a percent (%) character. An optional numeric
|
||||
field width may also be specified between the percent and the escape
|
||||
letter (e.g. "bf(%-50n %8l %07p)").
|
||||
In addition, one or more apostrophes may be specified prior to a numerical
|
||||
escape to indicate that the numerical value should be made more human-readable.
|
||||
The 3 supported levels are the same as for the bf(--human-readable)
|
||||
command-line option, though the default is for human-readability to be off.
|
||||
Each added apostrophe increases the level (e.g. "bf(%''l %'b %f)").
|
||||
|
||||
The default log format is "%o %h [%a] %m (%u) %f %l", and a "%t [%p] "
|
||||
is always prefixed when using the "log file" parameter.
|
||||
|
||||
Reference in new issue
Block a user