diff options
| author | ruki <[email protected]> | 2017-12-07 22:46:25 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-12-08 14:10:23 +0800 |
| commit | cb44535305f596bd757ffb58e5ae3cde6d3589fa (patch) | |
| tree | 343f0ff9287b90204a6a000e0af1a7a1ed6c640b /xmake/core/base/log.lua | |
| parent | abe87994168053e4f420a8b7ab286c65b546eaae (diff) | |
improve log and add color attrs for curses
Diffstat (limited to 'xmake/core/base/log.lua')
| -rw-r--r-- | xmake/core/base/log.lua | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/xmake/core/base/log.lua b/xmake/core/base/log.lua index e9b05f8c1..3ba6589a0 100644 --- a/xmake/core/base/log.lua +++ b/xmake/core/base/log.lua @@ -26,11 +26,11 @@ local log = log or {} -- get the log file -function log.file() +function log:file() -- get the output file - if log._FILE == nil then - local outputfile = log.outputfile() + if self._FILE == nil then + local outputfile = self:outputfile() if outputfile then -- get directory @@ -48,48 +48,48 @@ function log.file() end -- open the log file - log._FILE = io.open(outputfile, 'w+') + self._FILE = io.open(outputfile, 'w+') end - log._FILE = log._FILE or false + self._FILE = self._FILE or false end - return log._FILE + return self._FILE end -- get the output file -function log.outputfile() - if log._LOGFILE == nil then - log._LOGFILE = os.getenv("XMAKE_LOGFILE") or false +function log:outputfile() + if self._LOGFILE == nil then + self._LOGFILE = os.getenv("XMAKE_LOGFILE") or false end - return log._LOGFILE + return self._LOGFILE end -- flush log to file -function log.flush() - local file = log.file() +function log:flush() + local file = log:file() if file then io.flush(file) end end -- close the log file -function log.close() - local file = log.file() +function log:close() + local file = log:file() if file then file:close() end end -- print log to the log file -function log.print(...) - local file = log.file() +function log:print(...) + local file = log:file() if file then file:write(string.format(...) .. "\n") end end -- print variables to the log file -function log.printv(...) - local file = log.file() +function log:printv(...) + local file = log:file() if file then local values = {...} for i, v in ipairs(values) do @@ -108,8 +108,8 @@ function log.printv(...) end -- printf log to the log file -function log.printf(...) - local file = log.file() +function log:printf(...) + local file = self:file() if file then file:write(string.format(...)) end @@ -117,7 +117,7 @@ end -- write log the log file function log:write(...) - local file = log.file() + local file = self:file() if file then file:write(...) end |
