summaryrefslogtreecommitdiff
path: root/xmake/core/base
diff options
context:
space:
mode:
authorruki <[email protected]>2017-12-14 00:46:35 +0800
committerruki <[email protected]>2017-12-13 22:39:31 +0800
commit42cc615918ee1e4cc3ce435172e9f91dc1df1086 (patch)
tree323c0dbb450f137d1b15eb31a0f279dcd2675309 /xmake/core/base
parent2694f86469cdd776ba2caba9bcd7ec261457aa2c (diff)
fix log and application bug
Diffstat (limited to 'xmake/core/base')
-rw-r--r--xmake/core/base/log.lua25
1 files changed, 21 insertions, 4 deletions
diff --git a/xmake/core/base/log.lua b/xmake/core/base/log.lua
index 3ba6589a0..332d267bb 100644
--- a/xmake/core/base/log.lua
+++ b/xmake/core/base/log.lua
@@ -28,6 +28,11 @@ local log = log or {}
-- get the log file
function log:file()
+ -- disable?
+ if self._ENABLE ~= nil and not self._ENABLE then
+ return
+ end
+
-- get the output file
if self._FILE == nil then
local outputfile = self:outputfile()
@@ -63,9 +68,21 @@ function log:outputfile()
return self._LOGFILE
end
+-- clear log
+function log:clear(state)
+ if os.isfile(self:outputfile()) then
+ io.writefile(self:outputfile(), "")
+ end
+end
+
+-- enable log
+function log:enable(state)
+ self._ENABLE = state
+end
+
-- flush log to file
function log:flush()
- local file = log:file()
+ local file = self:file()
if file then
io.flush(file)
end
@@ -73,7 +90,7 @@ end
-- close the log file
function log:close()
- local file = log:file()
+ local file = self:file()
if file then
file:close()
end
@@ -81,7 +98,7 @@ end
-- print log to the log file
function log:print(...)
- local file = log:file()
+ local file = self:file()
if file then
file:write(string.format(...) .. "\n")
end
@@ -89,7 +106,7 @@ end
-- print variables to the log file
function log:printv(...)
- local file = log:file()
+ local file = self:file()
if file then
local values = {...}
for i, v in ipairs(values) do