[LOG] Add log level bypass support for logcat console
authorChristophe Guerard <christophe.guerard@intel.com>
Tue, 6 Mar 2012 15:20:11 +0000 (16:20 +0100)
committerbuildbot <buildbot@intel.com>
Tue, 20 Mar 2012 19:46:02 +0000 (12:46 -0700)
BZ: 25924

To collect all the kernel logs and ignore the log level set in the
kernel command line for one specific console, a new console setting
is created named CON_IGNORELEVEL meaning that all the logs whatever its level
is displayed on this console. With this granularity, the consoles impacting
power consumption do not set CON_IGNORELEVEL and the one used to save kernel logs
into the file system (named logk) could set CON_IGNORELEVEL

Change-Id: If9b7a0918ddd189ffabdf87d7ad5b8a0f5281d86
Signed-off-by: Christophe Guerard <christophe.guerard@intel.com>
Reviewed-on: http://android.intel.com:8080/37736
Reviewed-by: Rocher, JeremyX <jeremyx.rocher@intel.com>
Reviewed-by: Hogander, Jouni <jouni.hogander@intel.com>
Reviewed-by: Continente, Christophe <christophe.continente@intel.com>
Reviewed-by: Tardy, Pierre <pierre.tardy@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/staging/android/logger.c
include/linux/console.h
kernel/printk.c

index 6f9b00a..ee8e7a2 100755 (executable)
@@ -758,10 +758,14 @@ logger_console_write(struct console *console, const char *s, unsigned int count)
        schedule_work(&write_console_wq);
 }
 
+/* logger console uses CON_IGNORELEVEL that provides a way to ignore
+ * the log level set in the kernel command line
+ */
+
 static struct console logger_console = {
        .name   = "logk",
        .write  = logger_console_write,
-       .flags  = CON_PRINTBUFFER,
+       .flags  = CON_PRINTBUFFER | CON_IGNORELEVEL,
        .index  = -1,
 };
 
index 7453cfd..ca9cd60 100644 (file)
@@ -110,6 +110,7 @@ int con_debug_leave(void);
 #define CON_BOOT       (8)
 #define CON_ANYTIME    (16) /* Safe to call when cpu is offline */
 #define CON_BRL                (32) /* Used for a braille device */
+#define CON_IGNORELEVEL        (64) /* Used to ignore log level for a console */
 
 struct console {
        char    name[16];
index dc5aefe..d5a692b 100644 (file)
@@ -553,23 +553,6 @@ void kdb_syslog_data(char *syslog_data[4])
 }
 #endif /* CONFIG_KGDB_KDB */
 
-/*
- * Call the console drivers on a range of log_buf
- */
-static void __call_console_drivers(unsigned start, unsigned end)
-{
-       struct console *con;
-
-       for_each_console(con) {
-               if (exclusive_console && con != exclusive_console)
-                       continue;
-               if ((con->flags & CON_ENABLED) && con->write &&
-                               (cpu_online(smp_processor_id()) ||
-                               (con->flags & CON_ANYTIME)))
-                       con->write(con, &LOG_BUF(start), end - start);
-       }
-}
-
 static int __read_mostly ignore_loglevel;
 
 static int __init ignore_loglevel_setup(char *str)
@@ -581,6 +564,24 @@ static int __init ignore_loglevel_setup(char *str)
 }
 
 early_param("ignore_loglevel", ignore_loglevel_setup);
+/*
+ * Call the console drivers on a range of log_buf
+ */
+static void __call_console_drivers(unsigned start, unsigned end, int loglevel)
+{
+       struct console *con;
+
+       for_each_console(con) {
+               if (exclusive_console && con != exclusive_console)
+                       continue;
+               if (((con->flags & CON_IGNORELEVEL) || ignore_loglevel ||
+                       loglevel < console_loglevel) &&
+                       (con->flags & CON_ENABLED) && con->write &&
+                       (cpu_online(smp_processor_id()) ||
+                       (con->flags & CON_ANYTIME)))
+                               con->write(con, &LOG_BUF(start), end - start);
+       }
+}
 
 /*
  * Write out chars from start to end - 1 inclusive
@@ -588,15 +589,15 @@ early_param("ignore_loglevel", ignore_loglevel_setup);
 static void _call_console_drivers(unsigned start,
                                unsigned end, int msg_log_level)
 {
-       if ((msg_log_level < console_loglevel || ignore_loglevel) &&
-                       console_drivers && start != end) {
+       if (console_drivers && start != end) {
                if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
                        /* wrapped write */
                        __call_console_drivers(start & LOG_BUF_MASK,
-                                               log_buf_len);
-                       __call_console_drivers(0, end & LOG_BUF_MASK);
+                                               log_buf_len, msg_log_level);
+                       __call_console_drivers(0, end & LOG_BUF_MASK,
+                                                               msg_log_level);
                } else {
-                       __call_console_drivers(start, end);
+                       __call_console_drivers(start, end, msg_log_level);
                }
        }
 }