summaryrefslogtreecommitdiff
path: root/xmake/core/base/log.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-10-16 22:33:11 +0800
committerruki <[email protected]>2017-10-16 09:19:07 +0800
commita08d6c9117e33b2742ce992f8217090bdcdd568f (patch)
tree72ab410c128845a802acdffe07e3d635954de7f6 /xmake/core/base/log.lua
parente6b23ffc316822a52b374e1c38dff738c7be6b91 (diff)
fix log bug
Diffstat (limited to 'xmake/core/base/log.lua')
-rw-r--r--xmake/core/base/log.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/xmake/core/base/log.lua b/xmake/core/base/log.lua
index 57f2dc1a2..186a4ce30 100644
--- a/xmake/core/base/log.lua
+++ b/xmake/core/base/log.lua
@@ -27,9 +27,27 @@ local log = log or {}
-- get the log file
function log.file()
+
+ -- get the output file
if log._FILE == nil then
local outputfile = log.outputfile()
- if outputfile and os.isfile(outputfile) then
+ if outputfile then
+
+ -- get directory
+ local i = outputfile:find_last("[/\\]")
+ if i then
+ if i > 1 then i = i - 1 end
+ dir = outputfile:sub(1, i)
+ else
+ dir = "."
+ end
+
+ -- ensure the directory
+ if not os.isdir(dir) then
+ os.mkdir(dir)
+ end
+
+ -- open the log file
log._FILE = io.open(outputfile, 'w')
end
log._FILE = log._FILE or false
@@ -49,7 +67,7 @@ end
function log.flush()
local file = log.file()
if file then
- file:flush()
+ io.flush(file)
end
end