summaryrefslogtreecommitdiff
path: root/rpmio/rpmlog.h
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-12-07 13:16:45 +0200
committerPanu Matilainen <pmatilai@redhat.com>2007-12-07 13:16:45 +0200
commita5f65886f897223fbb476c6ddb8c9f4b7d81d6a3 (patch)
treeb0179f4e185d6c77e9aa9856a44c342637b0be34 /rpmio/rpmlog.h
parentca9ff17a4d21ec6ba78a56a0f1ddae7e8e16682e (diff)
downloadrpm-a5f65886f897223fbb476c6ddb8c9f4b7d81d6a3.tar.gz
rpm-a5f65886f897223fbb476c6ddb8c9f4b7d81d6a3.tar.bz2
rpm-a5f65886f897223fbb476c6ddb8c9f4b7d81d6a3.zip
Logging enhancements
- add parameters to rpmlogCallback: current log record pointer + optional user data - callback return flags to enable/disable default logging behavior and to perform exit() after cleaning up - add method for retrieving prefix string for a given message priority - move default logging behavior out of rpmlog() proper
Diffstat (limited to 'rpmio/rpmlog.h')
-rw-r--r--rpmio/rpmlog.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/rpmio/rpmlog.h b/rpmio/rpmlog.h
index e1281a78b..d9f38649a 100644
--- a/rpmio/rpmlog.h
+++ b/rpmio/rpmlog.h
@@ -149,15 +149,27 @@ RPMCODE facilitynames[] =
#define RPMLOG_NOWAIT 0x10 /*!< don't wait for console forks: DEPRECATED */
#define RPMLOG_PERROR 0x20 /*!< log to stderr as well */
-/** \ingroup rpmlog
- * @todo Add argument(s), integrate with other types of callbacks.
+/* \ingroup rpmlog
+ * Option flags for callback return value.
*/
-typedef void (*rpmlogCallback) (void);
+#define RPMLOG_CONT 0x01 /*!< perform default logging */
+#define RPMLOG_EXIT 0x02 /*!< exit after logging */
/** \ingroup rpmlog
*/
typedef struct rpmlogRec_s * rpmlogRec;
+typedef void * rpmlogCallbackData;
+
+/** \ingroup rpmlog
+ * @param rec rpmlog record
+ * @param data private callback data
+ * @return flags to define further behavior:
+ * RPMLOG_CONT to continue to default logger,
+ * RPMLOG_EXIT to exit after processing
+ */
+typedef int (*rpmlogCallback) (rpmlogRec rec, rpmlogCallbackData data);
+
/** \ingroup rpmlog
* Return number of rpmError() ressages.
* @return number of messages
@@ -210,11 +222,19 @@ const char * rpmlogMessage(void);
int rpmlogCode(void);
/** \ingroup rpmlog
+ * Return translated prefix string (if any) given log level.
+ * @param pri log priority
+ * @return message prefix (or "" for none)
+ */
+const char * rpmlogLevelPrefix(rpmlogLvl pri);
+
+/** \ingroup rpmlog
* Set rpmlog callback function.
* @param cb rpmlog callback function
+ * @param data callback private (user) data
* @return previous rpmlog callback function
*/
-rpmlogCallback rpmlogSetCallback(rpmlogCallback cb);
+rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data);
/** \ingroup rpmlog
* Set rpmlog file handle.