summaryrefslogtreecommitdiff
path: root/xmake/core/base/utils.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-10-15 23:43:33 +0800
committerruki <[email protected]>2017-10-15 23:43:33 +0800
commite6b23ffc316822a52b374e1c38dff738c7be6b91 (patch)
tree2747ccf724916cf69a327810904cc808ea728423 /xmake/core/base/utils.lua
parent3c990e889dc116dec50c950f5c1a1a91fb5d6600 (diff)
enable log output
Diffstat (limited to 'xmake/core/base/utils.lua')
-rw-r--r--xmake/core/base/utils.lua41
1 files changed, 34 insertions, 7 deletions
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua
index 772d1f162..49b05ea0a 100644
--- a/xmake/core/base/utils.lua
+++ b/xmake/core/base/utils.lua
@@ -30,6 +30,7 @@ local option = require("base/option")
local colors = require("base/colors")
local string = require("base/string")
local table = require("base/table")
+local log = require("base/log")
-- print string with newline
function utils._print(...)
@@ -70,8 +71,14 @@ function utils.print(format, ...)
-- check
assert(format)
+ -- init message
+ local message = string.tryformat(format, ...)
+
-- trace
- utils._print(string.tryformat(format, ...))
+ utils._print(message)
+
+ -- write to the log file
+ log.printv(message)
end
-- print format string without newline
@@ -80,8 +87,14 @@ function utils.printf(format, ...)
-- check
assert(format)
+ -- init message
+ local message = string.tryformat(format, ...)
+
-- trace
- utils._iowrite(string.tryformat(format, ...))
+ utils._iowrite(message)
+
+ -- write to the log file
+ log.write(message)
end
-- print format string and colors with newline
@@ -90,8 +103,16 @@ function utils.cprint(format, ...)
-- check
assert(format)
+ -- init message
+ local message = string.tryformat(format, ...)
+
-- trace
- utils._print(colors.translate(string.tryformat(format, ...)))
+ utils._print(colors.translate(message))
+
+ -- write to the log file
+ if log.file() then
+ log.printv(colors.ignore(message))
+ end
end
-- print format string and colors without newline
@@ -100,8 +121,16 @@ function utils.cprintf(format, ...)
-- check
assert(format)
+ -- init message
+ local message = string.tryformat(format, ...)
+
-- trace
- utils._iowrite(colors.translate(string.tryformat(format, ...)))
+ utils._iowrite(colors.translate(message))
+
+ -- write to the log file
+ if log.file() then
+ log.write(colors.ignore(message))
+ end
end
-- the verbose function
@@ -109,9 +138,7 @@ function utils.verbose(format, ...)
-- enable verbose?
if option.get("verbose") and format ~= nil then
-
- -- trace
- utils._print(string.tryformat(format, ...))
+ utils.print(format, ...)
end
end