We now allow you to specify log levels separately for each log domain.
# The port to run HTTP server on. 0 means dynamic.
port=0
-# The log level
+# Comma-separated list of domain:level pairs to specify log level thresholds for
+# individual domains. domain could be either 'rygel', name of a plugin or '*'
+# for all domains. Allowed levels are:
#
# 1=critical
# 2=error
# 3=warning
# 4=message/info
# 5=debug
-#
-log-level=4
+log-levels=*:4
# Allow upload of media files?
allow-upload=true
private static bool disallow_upload;
private static bool disallow_deletion;
- private static LogLevel log_level = LogLevel.INVALID;
+ private static string log_levels;
private static string plugin_path;
ref disallow_upload, "Disallow upload", null },
{ "disallow-deletion", 'D', 0, OptionArg.NONE,
ref disallow_deletion, "Disallow deletion", null },
- { "log-level", 'g', 0, OptionArg.INT, ref log_level,
- "Log level. 1=critical,2=error,3=warning,4=message/info,5=debug",
- "N" },
+ { "log-levels", 'g', 0, OptionArg.STRING, ref log_levels,
+ "Comma-separated list of domain:level pairs to specify log level " +
+ "thresholds for individual domains. domain could be either " +
+ "'rygel', name of a plugin or '*' for all domains. " +
+ " Allowed levels are: " +
+ "0=critical,2=error,3=warning,4=message/info,5=debug.",
+ "DOMAIN1:LEVEL1[,DOMAIN2:LEVEL2,..]" },
{ "plugin-path", 'u', 0, OptionArg.STRING, ref plugin_path,
"Plugin Path", "PLUGIN_PATH" },
{ "disable-plugin", 'd', 0, OptionArg.STRING_ARRAY,
}
}
- public LogLevel get_log_level () throws GLib.Error {
- if (this.log_level == LogLevel.INVALID) {
+ public string get_log_levels () throws GLib.Error {
+ if (log_levels == null) {
throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
}
- return log_level;
+ return log_levels;
}
public string get_plugin_path () throws GLib.Error {
public abstract bool get_allow_deletion () throws GLib.Error;
- public abstract LogLevel get_log_level () throws GLib.Error;
+ public abstract string get_log_levels () throws GLib.Error;
public abstract string get_plugin_path () throws GLib.Error;
private static string WMV_TRANSCODING_ENV = DISABLE_PREFIX + "_WMV_TRANS";
private static string DISALLOW_UPLOAD_ENV = DISABLE_PREFIX + "_UPLOAD";
private static string DISALLOW_DELETION_ENV = DISABLE_PREFIX + "_DELETION";
- private static string LOG_LEVEL_ENV = RYGEL_PREFIX + "_LOG";
+ private static string LOG_LEVELS_ENV = RYGEL_PREFIX + "_LOG";
private static string PLUGIN_PATH_ENV = RYGEL_PREFIX + "_PLUGIN_PATH";
// Our singleton
return !this.get_bool_variable (DISALLOW_DELETION_ENV);
}
- public LogLevel get_log_level () throws GLib.Error {
- return (LogLevel) this.get_int_variable (LOG_LEVEL_ENV,
- LogLevel.CRITICAL,
- LogLevel.DEBUG);
+ public string get_log_levels () throws GLib.Error {
+ return this.get_string_variable (LOG_LEVELS_ENV);
}
public string get_plugin_path () throws GLib.Error {
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+using Gee;
+
public enum Rygel.LogLevel {
INVALID = 0,
CRITICAL = 1,
}
public class Rygel.LogHandler : GLib.Object {
- private const LogLevelFlags DEFAULT_LEVELS = LogLevelFlags.LEVEL_WARNING |
- LogLevelFlags.LEVEL_CRITICAL |
- LogLevelFlags.LEVEL_ERROR |
- LogLevelFlags.LEVEL_MESSAGE |
- LogLevelFlags.LEVEL_INFO;
+ private const string DEFAULT_LEVELS = "*:4";
+ private const LogLevelFlags DEFAULT_FLAGS = LogLevelFlags.LEVEL_WARNING |
+ LogLevelFlags.LEVEL_CRITICAL |
+ LogLevelFlags.LEVEL_ERROR |
+ LogLevelFlags.LEVEL_MESSAGE |
+ LogLevelFlags.LEVEL_INFO;
- public LogLevelFlags levels; // Current log levels
+ private HashMap<string,LogLevelFlags> log_level_hash;
private static LogHandler log_handler; // Singleton
}
private LogHandler () {
+ this.log_level_hash = new HashMap<string,LogLevelFlags> ();
+
// Get the allowed log levels from the config
var config = MetaConfig.get_default ();
+ string log_levels;
try {
- this.levels = this.log_level_to_flags (config.get_log_level ());
+ log_levels = config.get_log_levels ();
} catch (Error err) {
- this.levels = DEFAULT_LEVELS;
+ log_levels = DEFAULT_LEVELS;
warning (_("Failed to get log level from configuration: %s"),
err.message);
}
+ foreach (var pair in log_levels.split (",")) {
+ var tokens = pair.split (":");
+ if (unlikely (tokens.length < 2)) {
+ break;
+ }
+
+ var domain = tokens[0];
+ var levels = (LogLevel) tokens[1].to_int ();
+ var flags = this.log_level_to_flags (levels);
+
+ this.log_level_hash[domain] = flags;
+ }
+
Log.set_default_handler (this.log_func);
}
private void log_func (string? log_domain,
LogLevelFlags log_levels,
string message) {
- if (log_levels in this.levels) {
+ var flags = this.log_level_hash[log_domain];
+ if (flags == 0) {
+ flags = this.log_level_hash["*"];
+ }
+
+ if (log_levels in flags) {
// Forward the message to default domain
Log.default_handler (log_domain, log_levels, message);
}
}
private LogLevelFlags log_level_to_flags (LogLevel level) {
- LogLevelFlags flags = DEFAULT_LEVELS;
+ LogLevelFlags flags = DEFAULT_FLAGS;
switch (level) {
case LogLevel.CRITICAL:
LogLevelFlags.LEVEL_DEBUG;
break;
default:
- flags = DEFAULT_LEVELS;
+ flags = DEFAULT_FLAGS;
break;
}
return val;
}
- public LogLevel get_log_level () throws GLib.Error {
- LogLevel val = LogLevel.DEFAULT;
+ public string get_log_levels () throws GLib.Error {
+ string val = null;
bool unavailable = true;
foreach (var config in this.configs) {
try {
- val = config.get_log_level ();
+ val = config.get_log_levels ();
unavailable = false;
break;
} catch (GLib.Error err) {}
public static const string WMV_TRANSCODER_KEY = "enable-wmv-transcoder";
public static const string ALLOW_UPLOAD_KEY = "allow-upload";
public static const string ALLOW_DELETION_KEY = "allow-deletion";
- public static const string LOG_LEVEL_KEY = "log-level";
+ public static const string LOG_LEVELS_KEY = "log-levels";
public static const string PLUGIN_PATH_KEY = "plugin-path";
// Our singleton
return this.get_bool ("general", ALLOW_DELETION_KEY);
}
- public LogLevel get_log_level () throws GLib.Error {
- return (LogLevel) this.get_int ("general",
- LOG_LEVEL_KEY,
- LogLevel.INVALID,
- LogLevel.DEBUG);
+ public string get_log_levels () throws GLib.Error {
+ return this.get_string ("general", LOG_LEVELS_KEY);
}
public string get_plugin_path () throws GLib.Error {