Skip to content

Commit d495ce1

Browse files
authored
Merge pull request #36 from open-watt/logging_bugs
Fix several logging bugs
2 parents 3164ae6 + fe37a7e commit d495ce1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/urt/log.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void writeLogf(T...)(Level level, const(char)[] format, ref T things)
5353
if (level > logLevel)
5454
return;
5555

56-
const(char)[] message = tformat("{0}: {@-2}", levelNames[level], things, format);
56+
const(char)[] message = tformat("{-2}: {@-1}", things, levelNames[level], format);
5757

5858
for (size_t i = 0; i < g_log_sink_count; i++)
5959
g_log_sinks[i](level, message);

src/urt/string/format.d

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ struct DefFormat(T)
344344
}
345345

346346
static if (is(T == long))
347-
size_t len = format_int(value, buffer, base, cast(uint)padding, leadingZeroes ? '0' : ' ', show_sign);
347+
ptrdiff_t len = format_int(value, buffer, base, cast(uint)padding, leadingZeroes ? '0' : ' ', show_sign);
348348
else
349-
size_t len = format_uint(value, buffer, base, cast(uint)padding, leadingZeroes ? '0' : ' ');
349+
ptrdiff_t len = format_uint(value, buffer, base, cast(uint)padding, leadingZeroes ? '0' : ' ');
350350

351351
if (to_lower && len > 0)
352352
{
@@ -473,6 +473,8 @@ struct DefFormat(T)
473473
}
474474

475475
char[] hex = toHexString(cast(ubyte[])value, buffer, grp1, grp2);
476+
if (!hex.ptr)
477+
return -1;
476478
return hex.length;
477479
}
478480
else static if (is(T : const U[], U))
@@ -861,6 +863,8 @@ ptrdiff_t parseFormat(ref const(char)[] format, ref char[] buffer, const(FormatA
861863
if (bytes < 0)
862864
return -2;
863865
char[] t = formatImpl(buffer, indirectFormat.ptr[0 .. bytes], args);
866+
if (!t.ptr)
867+
return -1;
864868
len = t.length;
865869
}
866870
else

0 commit comments

Comments
 (0)