Changeset: b000d4866543 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b000d4866543
Modified Files:
gdk/gdk_tracer.c
gdk/gdk_tracer.h
Branch: default
Log Message:
Layout + some minor changes.
diffs (truncated from 412 to 300 lines):
diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -123,7 +123,7 @@ static int
// vsnprintf(char *str, size_t count, ...) -> including null
terminating character
bytes_written = vsnprintf(sel_tracer->buffer
+sel_tracer->allocated_size, BUFFER_SIZE - sel_tracer->allocated_size, fmt, va);
// Add \n if it doesn't exist
- if (bytes_written && fmt[fmt_len - 1] != NEW_LINE)
+ if (bytes_written && fmt[fmt_len - 1] != '\n')
bytes_written += snprintf(sel_tracer->buffer
+sel_tracer->allocated_size, BUFFER_SIZE - sel_tracer->allocated_size, "\n");
// Let GDKtracer_log to know about the failure
diff --git a/gdk/gdk_tracer.h b/gdk/gdk_tracer.h
--- a/gdk/gdk_tracer.h
+++ b/gdk/gdk_tracer.h
@@ -8,24 +8,28 @@
/* // TODO: Complete it when documentation is accepted
*
- * Tracer is the general logging system for the MonetDB stack modelled after
the
- * well-known logging schemes (e.g: Python). It provides a number of logging
levels
- * and options to increase or reduce the verbosity either of individual code
parts
- * or of the codebase as a whole. It allows users to focus on logging messages
- * related to certain steps of execution, which can be proved handy when it
comes
- * to debugging. The behavior of Tracer can be controlled at runtime using the
- * SQL API described later on. Certain calls require an "id" to operate which
can
- * be found on the list of each section below.
+ * Tracer is the general logging system for the MonetDB stack modelled
+ * after the well-known logging schemes (e.g: Python). It provides a
+ * number of logging levels and options to increase or reduce the
+ * verbosity either of individual code parts or of the codebase as a
+ * whole. It allows users to focus on logging messages related to
+ * certain steps of execution, which can be proved handy when it comes
+ * to debugging. The behavior of Tracer can be controlled at runtime
+ * using the SQL API described later on. Certain calls require an "id"
+ * to operate which can be found on the list of each section below.
*
- * Internally, the logger uses a buffer to capture log messages before they are
- * forwarded to the specific adapter.
+ * Internally, the logger uses a buffer to capture log messages before
+ * they are forwarded to the specific adapter.
*
- * - Sets the minimum flush level that an event will trigger the logger to
flush the buffer
- * - Produces messages to the output stream. It is also used as a fallback
mechanism
- * in case GDKtracer fails to log for whatever reason.
+ * - Sets the minimum flush level that an event will trigger the
+ * logger to flush the buffer
+ * - Produces messages to the output stream. It is also used as a
+ * fallback mechanism in case GDKtracer fails to log for whatever
+ * reason.
* - Struct buffer with allocated space etc.
* - Flush buffer sends the messages to the selected adapter
- * - Write about the log structure (e.g: MT_thread_get_name + datetime + blah
blah)
+ * - Write about the log structure (e.g: MT_thread_get_name + datetime
+ * + blah blah)
*/
#ifndef _GDK_TRACER_H_
@@ -41,7 +45,6 @@
#define FILE_NAME "mdbtrace.log"
#define NAME_SEP '_'
#define NULL_CHAR '\0'
-#define NEW_LINE '\n'
#define MXW "20"
#define OPENFILE_FAILED "Failed to open "FILE_NAME
@@ -50,19 +53,17 @@
#define AS_STR(x) #x
#define STR(x) AS_STR(x)
-#define __FILENAME__ __FILE__
-
#define GENERATE_ENUM(ENUM) ENUM,
#define GENERATE_STRING(STRING) #STRING,
#define GENERATE_LOG_LEVEL(COMP) DEFAULT_LOG_LEVEL,
// ADAPTERS
-#define FOREACH_ADPTR(ADPTR) \
+#define FOREACH_ADPTR(ADPTR) \
ADPTR( BASIC ) \
ADPTR( PROFILER ) \
- \
- ADPTR( ADAPTERS_COUNT ) \
+ \
+ ADPTR( ADAPTERS_COUNT )
typedef enum {
FOREACH_ADPTR(GENERATE_ENUM)
@@ -71,14 +72,14 @@ typedef enum {
// LOG LEVELS
-#define FOREACH_LEVEL(LEVEL) \
+#define FOREACH_LEVEL(LEVEL) \
LEVEL( M_CRITICAL ) \
LEVEL( M_ERROR ) \
LEVEL( M_WARNING ) \
LEVEL( M_INFO ) \
LEVEL( M_DEBUG ) \
- \
- LEVEL( LOG_LEVELS_COUNT ) \
+ \
+ LEVEL( LOG_LEVELS_COUNT )
typedef enum {
FOREACH_LEVEL(GENERATE_ENUM)
@@ -91,13 +92,13 @@ static const char *LEVEL_STR[] = {
// LAYERS
-#define FOREACH_LAYER(LAYER) \
+#define FOREACH_LAYER(LAYER) \
LAYER( MDB_ALL ) \
LAYER( SQL_ALL ) \
LAYER( MAL_ALL ) \
LAYER( GDK_ALL ) \
- \
- LAYER( LAYERS_COUNT ) \
+ \
+ LAYER( LAYERS_COUNT )
typedef enum {
FOREACH_LAYER(GENERATE_ENUM)
@@ -113,44 +114,44 @@ typedef enum {
*
*/
// COMPONENTS
-#define FOREACH_COMP(COMP) \
+#define FOREACH_COMP(COMP) \
COMP( ALLOC ) \
- COMP( PAR ) \
+ COMP( PAR ) \
COMP( ALGO ) \
COMP( DELTA ) \
- COMP( IO_ ) \
- COMP( TEM ) \
+ COMP( IO_ ) \
+ COMP( TEM ) \
COMP( HEAP ) \
COMP( BAT_ ) \
COMP( ACCELERATOR ) \
COMP( TRACE ) \
COMP( CHECK_ ) \
COMP( THRD ) \
- \
+ \
COMP( GEOM ) \
COMP( LIDAR ) \
COMP( BAM_ ) \
COMP( FITS ) \
- COMP( SHP ) \
- \
+ COMP( SHP ) \
+ \
COMP( SQL_ATOM_TR ) \
- COMP( SQL_STATISTICS ) \
- COMP( SQL_ORDERIDX ) \
- COMP( SQL_OPTIMIZER ) \
+ COMP( SQL_STATISTICS ) \
+ COMP( SQL_ORDERIDX ) \
+ COMP( SQL_OPTIMIZER ) \
COMP( SQL_WLR ) \
COMP( SQL_USER ) \
- COMP( SQL_SCENARIO ) \
- COMP( SQL_CACHE_TR ) \
+ COMP( SQL_SCENARIO ) \
+ COMP( SQL_CACHE_TR ) \
COMP( SQL_SYMBOL ) \
COMP( SQL_MVC ) \
COMP( SQL_STORE ) \
- COMP( SQL_UPGRADES ) \
- COMP( SQL_RELATION ) \
+ COMP( SQL_UPGRADES ) \
+ COMP( SQL_RELATION ) \
COMP( SQL_RESULT ) \
- COMP( SQL_STATEMENT ) \
+ COMP( SQL_STATEMENT ) \
COMP( SQL_BAT ) \
- \
- COMP( MAL_INTERPRETER ) \
+ \
+ COMP( MAL_INTERPRETER ) \
COMP( MAL_WLC ) \
COMP( MAL_REMOTE ) \
COMP( MAL_ATOMS ) \
@@ -158,21 +159,21 @@ typedef enum {
COMP( MAL_OLTP ) \
COMP( MAL_MAPI ) \
COMP( MAL_SERVER ) \
- COMP( MAL_DATAFLOW ) \
- COMP( MAL_MANIFOLD ) \
- COMP( MAL_EXCEPTION ) \
+ COMP( MAL_DATAFLOW ) \
+ COMP( MAL_MANIFOLD ) \
+ COMP( MAL_EXCEPTION ) \
COMP( MAL_MAL ) \
- \
- COMP( MAL_OPTIMIZER ) \
- \
+ \
+ COMP( MAL_OPTIMIZER ) \
+ \
COMP( GDK_TM ) \
COMP( GDK_UTILS ) \
COMP( GDK_POSIX ) \
COMP( GDK_SYSTEM ) \
- COMP( GDK_IMPRINTS ) \
+ COMP( GDK_IMPRINTS ) \
COMP( GDK_HASH ) \
- \
- COMP( COMPONENTS_COUNT ) \
+ \
+ COMP( COMPONENTS_COUNT )
typedef enum {
FOREACH_COMP(GENERATE_ENUM)
@@ -189,101 +190,105 @@ static const char *COMPONENT_STR[] = {
*/
gdk_export LOG_LEVEL LVL_PER_COMPONENT[];
-// If the LOG_LEVEL of the message is one of the following: CRITICAL, ERROR or
WARNING
-// it is logged no matter the component. In any other case the component is
taken into account
+// If the LOG_LEVEL of the message is one of the following: CRITICAL,
+// ERROR or WARNING it is logged no matter the component. In any other
+// case the component is taken into account
#define GDK_TRACER_TEST(LOG_LEVEL, COMP) \
- (LOG_LEVEL == M_CRITICAL || \
- LOG_LEVEL == M_ERROR || \
- LOG_LEVEL == M_WARNING || \
+ (LOG_LEVEL == M_CRITICAL || \
+ LOG_LEVEL == M_ERROR || \
+ LOG_LEVEL == M_WARNING || \
LVL_PER_COMPONENT[COMP] >= LOG_LEVEL)
#define IF_GDK_TRACER_LOG(LOG_LEVEL, COMP) \
if (GDK_TRACER_TEST(LOG_LEVEL, COMP))
-#define GDK_TRACER_LOG_BODY(LOG_LEVEL, COMP, MSG, ...) \
- GDKtracer_log(LOG_LEVEL,
\
- "%s "
\
- "%-"MXW"s "
\
- "%"MXW"s:%d "
\
- "%"MXW"s "
\
- "%-"MXW"s "
\
- "%-"MXW"s # "MSG,
\
- GDKtracer_get_timestamp("%Y-%m-%d %H:%M:%S",
(char[20]){0}, 20), \
- __FILENAME__,
\
- __FUNCTION__,
\
- __LINE__,
\
- LEVEL_STR[LOG_LEVEL],
\
- COMPONENT_STR[COMP],
\
- MT_thread_getname(),
\
+#define GDK_TRACER_LOG_BODY(LOG_LEVEL, COMP, MSG, ...) \
+ GDKtracer_log(LOG_LEVEL, \
+ "%s " \
+ "%-"MXW"s " \
+ "%"MXW"s:%d " \
+ "%"MXW"s " \
+ "%-"MXW"s " \
+ "%-"MXW"s # "MSG, \
+ GDKtracer_get_timestamp("%Y-%m-%d %H:%M:%S", \
+ (char[20]){0}, 20), \
+ __FILE__, \
+ __func__, \
+ __LINE__, \
+ LEVEL_STR[LOG_LEVEL], \
+ COMPONENT_STR[COMP], \
+ MT_thread_getname(), \
## __VA_ARGS__)
-#define GDK_TRACER_LOG(LOG_LEVEL, COMP, MSG, ...)
\
- do {
\
- IF_GDK_TRACER_LOG(LOG_LEVEL, COMP) {
\
- GDK_TRACER_LOG_BODY(LOG_LEVEL, COMP, MSG, ##
__VA_ARGS__); \
- }
\
+#define GDK_TRACER_LOG(LOG_LEVEL, COMP, MSG, ...) \
+ do { \
+ IF_GDK_TRACER_LOG(LOG_LEVEL, COMP) { \
+ GDK_TRACER_LOG_BODY(LOG_LEVEL, COMP, MSG, \
+ ## __VA_ARGS__); \
+ } \
} while (0)
-#define TRC_CRITICAL(COMP, MSG, ...) \
+#define TRC_CRITICAL(COMP, MSG, ...) \
GDK_TRACER_LOG(M_CRITICAL, COMP, MSG, ## __VA_ARGS__)
-#define TRC_ERROR(COMP, MSG, ...) \
+#define TRC_ERROR(COMP, MSG, ...) \
GDK_TRACER_LOG(M_ERROR, COMP, MSG, ## __VA_ARGS__)
-#define TRC_WARNING(COMP, MSG, ...) \
+#define TRC_WARNING(COMP, MSG, ...) \
GDK_TRACER_LOG(M_WARNING, COMP, MSG, ## __VA_ARGS__)
-#define TRC_INFO(COMP, MSG, ...) \
+#define TRC_INFO(COMP, MSG, ...) \
GDK_TRACER_LOG(M_INFO, COMP, MSG, ## __VA_ARGS__)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list