xmlhandlers: Don't restrict CDATA
[prosody.git] / core / loggingmanager.lua
index c26fdc719d57ea2c1753e20facc6fbdeeddcc327..3ec696d50049d1c67f17bbff30f8ecab3afda2dc 100644 (file)
@@ -1,6 +1,6 @@
 -- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
 -- 
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
@@ -17,6 +17,12 @@ local math_max, rep = math.max, string.rep;
 local os_date, os_getenv = os.date, os.getenv;
 local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring;
 
+if os.getenv("__FLUSH_LOG") then
+       local io_flush = io.flush;
+       local _io_write = io_write;
+       io_write = function(...) _io_write(...); io_flush(); end
+end
+
 local config = require "core.configmanager";
 local eventmanager = require "core.eventmanager";
 local logger = require "util.logger";
@@ -27,9 +33,9 @@ _G.log = logger.init("general");
 module "loggingmanager"
 
 -- The log config used if none specified in the config file
-local default_logging = { { to = "console" } };
+local default_logging = { { to = "console" , levels = { min = (debug_mode and "debug") or "info" } } };
 local default_file_logging = { { to = "file", levels = { min = (debug_mode and "debug") or "info" }, timestamps = true } };
-local default_timestamp = "%b %d %T";
+local default_timestamp = "%b %d %H:%M:%S";
 -- The actual config loggingmanager is using
 local logging_config = config.get("*", "core", "log") or default_logging;
 
@@ -88,7 +94,7 @@ function apply_sink_rules(sink_type)
                        end
                end
        elseif type(logging_config) == "string" and (not logging_config:match("^%*")) and sink_type == "file" then
-               -- User specified simply a filename, and the "file" sink type 
+               -- User specified simply a filename, and the "file" sink type
                -- was just added
                for _, sink_config in pairs(default_file_logging) do
                        sink_config.filename = logging_config;
@@ -122,7 +128,7 @@ function get_levels(criteria, set)
                                return set;
                        elseif in_range then
                                set[level] = true;
-                       end     
+                       end
                end
        end
        
@@ -155,12 +161,12 @@ function log_sink_types.stdout()
                if timestamps then
                        io_write(os_date(timestamps), " ");
                end
-               if ... then 
+               if ... then
                        io_write(name, rep(" ", sourcewidth-namelen), level, "\t", format(message, ...), "\n");
                else
                        io_write(name, rep(" ", sourcewidth-namelen), level, "\t", message, "\n");
                end
-       end     
+       end
 end
 
 do
@@ -191,7 +197,7 @@ do
                        if timestamps then
                                io_write(os_date(timestamps), " ");
                        end
-                       if ... then 
+                       if ... then
                                io_write(name, rep(" ", sourcewidth-namelen), getstring(logstyles[level], level), "\t", format(message, ...), "\n");
                        else
                                io_write(name, rep(" ", sourcewidth-namelen), getstring(logstyles[level], level), "\t", message, "\n");
@@ -231,7 +237,7 @@ function log_sink_types.file(config)
                if timestamps then
                        write(logfile, os_date(timestamps), " ");
                end
-               if ... then 
+               if ... then
                        write(logfile, name, "\t", level, "\t", format(message, ...), "\n");
                else
                        write(logfile, name, "\t" , level, "\t", message, "\n");