示例#1
0
void
mongoc_log (mongoc_log_level_t  log_level,
            const char         *log_domain,
            const char         *format,
            ...)
{
   va_list args;
   char *message;
   static mongoc_once_t once = MONGOC_ONCE_INIT;

   mongoc_once(&once, &_mongoc_ensure_mutex_once);

   if (!gLogFunc
#ifdef MONGOC_TRACE
         || (log_level == MONGOC_LOG_LEVEL_TRACE && !gLogTrace)
#endif
      ) {
      return;
   }

   BSON_ASSERT (format);

   va_start(args, format);
   message = bson_strdupv_printf(format, args);
   va_end(args);

   mongoc_mutex_lock(&gLogMutex);
   gLogFunc(log_level, log_domain, message, gLogData);
   mongoc_mutex_unlock(&gLogMutex);

   bson_free(message);
}
示例#2
0
void
mongoc_log (mongoc_log_level_t log_level,
            const char *log_domain,
            const char *format,
            ...)
{
   va_list args;
   char *message;
   int stop_logging;

   mongoc_once (&once, &_mongoc_ensure_mutex_once);

   stop_logging = !gLogFunc;
#ifdef MONGOC_TRACE
   stop_logging =
      stop_logging || (log_level == MONGOC_LOG_LEVEL_TRACE && !gLogTrace);
#endif
   if (stop_logging) {
      return;
   }

   BSON_ASSERT (format);

   va_start (args, format);
   message = bson_strdupv_printf (format, args);
   va_end (args);

   mongoc_mutex_lock (&gLogMutex);
   gLogFunc (log_level, log_domain, message, gLogData);
   mongoc_mutex_unlock (&gLogMutex);

   bson_free (message);
}
示例#3
0
char *
bson_strdup_printf (const char *format,
                    ...)
{
   va_list args;
   char *ret;

   va_start(args, format);
   ret = bson_strdupv_printf(format, args);
   va_end(args);

   return ret;
}
示例#4
0
char *
bson_strdup_printf (const char *format, /* IN */
                    ...)                /* IN */
{
   va_list args;
   char *ret;

   bson_return_val_if_fail (format, NULL);

   va_start (args, format);
   ret = bson_strdupv_printf (format, args);
   va_end (args);

   return ret;
}
示例#5
0
char *
bson_strdup_printf (const char *format, /* IN */
                    ...)                /* IN */
{
   va_list args;
   char *ret;

   BSON_ASSERT (format);

   va_start (args, format);
   ret = bson_strdupv_printf (format, args);
   va_end (args);

   return ret;
}
示例#6
0
void
bson_string_append_printf (bson_string_t *string,
                           const char    *format,
                           ...)
{
   va_list args;
   char *ret;

   BSON_ASSERT (string);
   BSON_ASSERT (format);

   va_start (args, format);
   ret = bson_strdupv_printf (format, args);
   va_end (args);
   bson_string_append (string, ret);
   bson_free (ret);
}
示例#7
0
int
mock_server_auto_ismaster (mock_server_t *server,
                           const char *response_json,
                           ...)
{
   char *formatted_response_json;
   va_list args;

   va_start (args, response_json);
   formatted_response_json = bson_strdupv_printf (response_json, args);
   va_end (args);

   return mock_server_autoresponds (server,
                                    auto_ismaster,
                                    (void *) formatted_response_json,
                                    bson_free);
}
示例#8
0
request_t *
mock_server_receives_command (mock_server_t *server,
                              const char *database_name,
                              mongoc_query_flags_t flags,
                              const char *command_json,
                              ...)
{
   va_list args;
   char *formatted_command_json = NULL;
   char *ns;
   sync_queue_t *q;
   request_t *request;

   va_start (args, command_json);
   if (command_json) {
      formatted_command_json = bson_strdupv_printf (command_json, args);
   }
   va_end (args);

   ns = bson_strdup_printf ("%s.$cmd", database_name);

   q = mock_server_get_queue (server);
   request = (request_t *) q_get (q, server->request_timeout_msec);

   if (request && !request_matches_query (request,
                                          ns,
                                          flags,
                                          0,
                                          1,
                                          formatted_command_json,
                                          NULL,
                                          true)) {
      request_destroy (request);
      request = NULL;
   }

   bson_free (formatted_command_json);
   bson_free (ns);

   return request;
}
示例#9
0
void
mongoc_log (mongoc_log_level_t  log_level,
            const char         *log_domain,
            const char         *format,
            ...)
{
    va_list args;
    char *message;

    bson_return_if_fail(format);

    va_start(args, format);
    message = bson_strdupv_printf(format, args);
    va_end(args);

    bson_mutex_lock(&gLogMutex);
    gLogFunc(log_level, log_domain, message, gLogData);
    bson_mutex_unlock(&gLogMutex);

    bson_free(message);
}
示例#10
0
void
mongoc_log (mongoc_log_level_t  log_level,
            const char         *log_domain,
            const char         *format,
            ...)
{
   va_list args;
   char *message;
   static mongoc_once_t once = MONGOC_ONCE_INIT;

   mongoc_once(&once, &_mongoc_ensure_mutex_once);

   bson_return_if_fail(format);

   va_start(args, format);
   message = bson_strdupv_printf(format, args);
   va_end(args);

   mongoc_mutex_lock(&gLogMutex);
   gLogFunc(log_level, log_domain, message, gLogData);
   mongoc_mutex_unlock(&gLogMutex);

   bson_free(message);
}