summaryrefslogtreecommitdiff
path: root/include/asterisk/logger.h
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2014-01-14 18:14:02 +0000
committerRichard Mudgett <rmudgett@digium.com>2014-01-14 18:14:02 +0000
commit828f339a9cb52cdcb62c28962d87a5187dc7c5bc (patch)
tree0081ea00504678b5bc432cbdad91ba77493b4dab /include/asterisk/logger.h
parentaced8bdd2e5d210f024be602bf5a1e70555ecec4 (diff)
verbosity: Fix performance of console verbose messages.
The per console verbose level feature as previously implemented caused a large performance penalty. The fix required some minor incompatibilities if the new rasterisk is used to connect to an earlier version. If the new rasterisk connects to an older Asterisk version then the root console verbose level is always affected by the "core set verbose" command of the remote console even though it may appear to only affect the current console. If an older version of rasterisk connects to the new version then the "core set verbose" command will have no effect. * Fixed the verbose performance by not generating a verbose message if nothing is going to use it and then filtered any generated verbose messages before actually sending them to the remote consoles. * Split the "core set debug" and "core set verbose" CLI commands to remove the per module verbose support that cannot work with the per console verbose level. * Added a silent option to the "core set verbose" command. * Fixed "core set debug off" tab completion. * Made "core show settings" list the current console verbosity in addition to the root console verbosity. * Changed the default verbose level of the 'verbose' setting in the logger.conf [logfiles] section. The default is now to once again follow the current root console level. As a result, using the AMI Command action with "core set verbose" could again set the root console verbose level and affect the verbose level logged. (closes issue AST-1252) Reported by: Guenther Kelleter Review: https://reviewboard.asterisk.org/r/3114/ ........ Merged revisions 405431 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 405432 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405436 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/logger.h')
-rw-r--r--include/asterisk/logger.h101
1 files changed, 86 insertions, 15 deletions
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index bbad84bb3..eda50351c 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -90,21 +90,29 @@ int logger_reload(void);
void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...);
-/*! Send a verbose message (based on verbose level)
- * \brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
- * ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
- * This will print the message to the console if the verbose level is set to a level >= 3
- * Note the absence of a comma after the VERBOSE_PREFIX_3. This is important.
- * VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.
- * \version 11 added level parameter
+/*!
+ * \brief Send a verbose message (based on verbose level)
+ *
+ * \details This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
+ *
+ * ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
+ *
+ * This will print the message to the console if the verbose level is set to a level >= 3
+ *
+ * Note the absence of a comma after the VERBOSE_PREFIX_3. This is important.
+ * VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.
+ *
+ * \version 11 added level parameter
*/
void __attribute__((format(printf, 5, 6))) __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...);
-/*! Send a verbose message (based on verbose level) with deliberately specified callid
- * \brief just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used
- * for the log without needing to bind it to a thread. NULL is a valid argument for this function and will
- * allow you to specify that a log will never display a call id even when there is a call id bound to the
- * thread.
+/*!
+ * \brief Send a verbose message (based on verbose level) with deliberately specified callid
+ *
+ * \details just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used
+ * for the log without needing to bind it to a thread. NULL is a valid argument for this function and will
+ * allow you to specify that a log will never display a call id even when there is a call id bound to the
+ * thread.
*/
void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, ...);
@@ -118,6 +126,14 @@ void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const ch
int ast_register_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
int ast_unregister_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
+/*
+ * These gymnastics are due to platforms which designate char as unsigned by
+ * default. Level is the negative character -- offset by 1, because \0 is
+ * the string terminator.
+ */
+#define VERBOSE_MAGIC2LEVEL(x) (((char) -*(signed char *) (x)) - 1)
+#define VERBOSE_HASMAGIC(x) (*(signed char *) (x) < 0)
+
void ast_console_puts(const char *string);
/*!
@@ -225,8 +241,9 @@ unsigned int ast_debug_get_by_module(const char *module);
* \brief Get the verbose level for a module
* \param module the name of module
* \return the verbose level
+ * \version 11.0.0 deprecated
*/
-unsigned int ast_verbose_get_by_module(const char *module);
+unsigned int ast_verbose_get_by_module(const char *module) __attribute__((deprecated));
/*!
* \brief Register a new logger level
@@ -371,8 +388,62 @@ void ast_callid_strnprint(char *buffer, size_t buffer_size, struct ast_callid *c
ast_log(AST_LOG_DEBUG, __VA_ARGS__); \
} while (0)
-#define ast_verb(level, ...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, __VA_ARGS__)
-#define ast_verb_callid(level, callid, ...) __ast_verbose_callid(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, callid, __VA_ARGS__)
+extern int ast_verb_sys_level;
+
+#define VERBOSITY_ATLEAST(level) ((level) <= ast_verb_sys_level)
+
+#define ast_verb(level, ...) \
+ do { \
+ if (VERBOSITY_ATLEAST(level) ) { \
+ __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, __VA_ARGS__); \
+ } \
+ } while (0)
+
+#define ast_verb_callid(level, callid, ...) \
+ do { \
+ if (VERBOSITY_ATLEAST(level) ) { \
+ __ast_verbose_callid(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, callid, __VA_ARGS__); \
+ } \
+ } while (0)
+
+/*!
+ * \brief Re-evaluate the system max verbosity level (ast_verb_sys_level).
+ *
+ * \return Nothing
+ */
+void ast_verb_update(void);
+
+/*!
+ * \brief Register this thread's console verbosity level pointer.
+ *
+ * \param level Where the verbose level value is.
+ *
+ * \return Nothing
+ */
+void ast_verb_console_register(int *level);
+
+/*!
+ * \brief Unregister this thread's console verbosity level.
+ *
+ * \return Nothing
+ */
+void ast_verb_console_unregister(void);
+
+/*!
+ * \brief Get this thread's console verbosity level.
+ *
+ * \retval verbosity level of the console.
+ */
+int ast_verb_console_get(void);
+
+/*!
+ * \brief Set this thread's console verbosity level.
+ *
+ * \param verb_level New level to set.
+ *
+ * \return Nothing
+ */
+void ast_verb_console_set(int verb_level);
#if defined(__cplusplus) || defined(c_plusplus)
}