]> git.e2factory.org Git - e2factory.git/commitdiff
e2lib.log(): make newline optional
authorTobias Ulmer <tu@emlix.com>
Mon, 8 Sep 2014 13:31:46 +0000 (15:31 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:18 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2lib.lua

index 7e51d2021e972b53f7b8e11b2b46d99f9432c3d2..414c193c41493a87679e0e833affa99892a258ad 100644 (file)
@@ -567,7 +567,8 @@ end
 -- is true
 -- @param level number: loglevel
 -- @param msg string: log message
-function e2lib.log(level, msg)
+-- @param nonewline Defaults to false. Do not append newline if set to true.
+function e2lib.log(level, msg, nonewline)
     if level < 1 or level > 4 then
         e2lib.log(1, "Internal error: invalid log level")
     end
@@ -578,7 +579,7 @@ function e2lib.log(level, msg)
 
     local log_prefix = "[" .. level .. "] "
 
-    if string.sub(msg, -1) ~= "\n"  then
+    if not nonewline and string.sub(msg, -1) ~= "\n"  then
         msg = msg.."\n"
     end