Skip to content

Commit b34df5e

Browse files
committed
Make sure log lines are actually written in log.txt
1 parent 4b1fbec commit b34df5e

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ and only contains the latest changes.
33
Its purpose is to be shown in Olympus when updating.
44

55
#changelog#
6-
Added timestamps and tags to logs
6+
Make sure log lines are actually written to log.txt

sharp/Logger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Logger(string tag) {
88
public void Error(string msg) => log("err", msg);
99

1010
private void log(string level, string msg) {
11-
Console.Error.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}][{tag}][{level}] {msg}");
11+
Console.Error.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{level}] [{tag}] {msg}");
1212
}
1313
}
1414
}

src/logger.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local function logger(tag)
22
local logger = {}
33
local function log(level, ...)
4-
print('[' .. os.date('%Y-%m-%d %H:%M:%S') .. ']', '[' .. tag .. ']', '[' .. level .. ']', ...)
4+
print('[' .. os.date('%Y-%m-%d %H:%M:%S') .. ']', '[' .. level .. ']', '[' .. tag .. ']', ...)
55
end
66

77
-- "..." lets us toss any number of arguments to the final call to "print"

src/main.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ local canvas
4040
local drawstats = {}
4141

4242
local function logDump()
43+
local contentWritten = false
4344
while true do
4445
local logLine = logChannel:pop()
4546
if not logLine then
4647
break
4748
end
4849
if logFile then
4950
logFile:write(logLine, "\n")
51+
contentWritten = true
5052
end
5153
if logList and not lldb then
5254
if logList.children[100] then
@@ -55,6 +57,9 @@ local function logDump()
5557
logList:addChild(uie.label(logLine))
5658
end
5759
end
60+
if contentWritten then
61+
logFile:flush()
62+
end
5863
end
5964

6065

@@ -155,6 +160,9 @@ function love.errhand(...)
155160
end
156161

157162
function love.load(args)
163+
utils = require("utils")
164+
log.debug("This is Olympus.Lua version", utils.trim(utils.load("version.txt") or "?"))
165+
158166
love.window.setDisplaySleepEnabled(true)
159167

160168
local userOS = love.system.getOS()
@@ -193,7 +201,6 @@ function love.load(args)
193201
end
194202
end
195203

196-
utils = require("utils")
197204
threader = require("threader")
198205

199206
fs = require("fs")
@@ -241,8 +248,6 @@ function love.load(args)
241248
log.debug("SDL2 version", love.versionSDLStr)
242249
end
243250

244-
log.debug("Olympus version", utils.trim(utils.load("version.txt") or "?"))
245-
246251
ui = require("ui")
247252
uie = require("ui.elements")
248253
uiu = require("ui.utils")

src/prethread.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ return function(raw)
4343
_print(...)
4444
local input = {...}
4545
local line = {}
46-
line[1] = "[[" .. id .. "]]"
4746
for i = 1, #input do
48-
line[i + 1] = tostring(input[i])
47+
line[i] = tostring(input[i])
4948
end
5049
log:push(table.concat(line, " "))
5150
end

0 commit comments

Comments
 (0)