• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ KAA_LOG_ERROR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中KAA_LOG_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ KAA_LOG_ERROR函数的具体用法?C++ KAA_LOG_ERROR怎么用?C++ KAA_LOG_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了KAA_LOG_ERROR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: kaa_log_collector_init

/*
 * Initializes Kaa log collector.
 */
kaa_error_t kaa_log_collector_init()
{
    kaa_error_t error_code = ext_unlimited_log_storage_create(&log_storage_context, kaa_context_->logger);
    if (error_code) {
        KAA_LOG_ERROR(kaa_context_->logger, error_code, "Failed to create log storage");
        return error_code;
    }

    error_code = ext_log_upload_strategy_by_volume_create(&log_upload_strategy_context
                                                        , kaa_context_->channel_manager
                                                        , kaa_context_->bootstrap_manager);

    if (error_code) {
        KAA_LOG_ERROR(kaa_context_->logger, error_code, "Failed to create log upload strategy");
        return error_code;
    }

    error_code = ext_log_upload_strategy_by_volume_set_threshold_count(log_upload_strategy_context
                                                                     , KAA_DEMO_UPLOAD_COUNT_THRESHOLD);

    error_code = kaa_logging_init(kaa_context_->log_collector
                                , log_storage_context
                                , log_upload_strategy_context);

    return error_code;
}
开发者ID:BioSoundSystems,项目名称:kaa,代码行数:29,代码来源:kaa_demo.c


示例2: kaa_client_init_operations_channel

kaa_error_t kaa_client_init_operations_channel(kaa_client_t *kaa_client)
{
    KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);
    kaa_error_t error_code = KAA_ERR_NONE;
    KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Start operations channel initialization");
    error_code = kaa_tcp_channel_create(&kaa_client->operations_channel
                                      , kaa_client->kaa_context->logger
                                      , OPERATIONS_SERVICES
                                      , OPERATIONS_SERVICES_COUNT);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Operations channel initialization failed");
        return error_code;
    }

    KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Initializing Kaa SDK Operations channel added to transport channel manager");

    error_code = kaa_channel_manager_add_transport_channel(kaa_client->kaa_context->channel_manager
                                                         , &kaa_client->operations_channel
                                                         , &kaa_client->operations_channel_id);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Error during Kaa operations channel setting as transport");
        return error_code;
    }

    KAA_LOG_INFO(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Operations channel initialized successfully");
    print_mem_stat(kaa_client);
    return error_code;
}
开发者ID:nthevu,项目名称:kaa,代码行数:28,代码来源:econais_ec19d_kaa_client.c


示例3: kaa_configuration_manager_request_serialize

kaa_error_t kaa_configuration_manager_request_serialize(kaa_configuration_manager_t *self, kaa_platform_message_writer_t *writer)
{
    KAA_RETURN_IF_NIL2(self, writer, KAA_ERR_BADPARAM);

    KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize client configuration sync");

    uint32_t payload_size = sizeof(uint32_t) + SHA_1_DIGEST_LENGTH;

    kaa_platform_message_writer_t tmp_writer = *writer;
    kaa_error_t error_code = kaa_platform_message_write_extension_header(&tmp_writer, KAA_CONFIGURATION_EXTENSION_TYPE, KAA_CONFIGURATION_ALL_FLAGS, payload_size);
    if (error_code) {
        KAA_LOG_ERROR(self->logger, error_code, "Failed to write configuration extension header");
        return KAA_ERR_WRITE_FAILED;
    }

    *((uint32_t *) tmp_writer.current) = KAA_HTONL(self->status->config_seq_n);
    tmp_writer.current += sizeof(uint32_t);

    KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Configuration state sequence number is '%d'", self->status->config_seq_n);

    error_code = kaa_platform_message_write_aligned(&tmp_writer, self->configuration_hash, SHA_1_DIGEST_LENGTH);
    if (error_code) {
        KAA_LOG_ERROR(self->logger, error_code, "Failed to write configuration hash");
        return KAA_ERR_WRITE_FAILED;
    }

    *writer = tmp_writer;

    return KAA_ERR_NONE;
}
开发者ID:aglne,项目名称:kaa,代码行数:30,代码来源:kaa_configuration_manager.c


示例4: esp8266_tcp_receive_fn

void esp8266_tcp_receive_fn(void *context, int id, const uint8 *buffer, const int receive_size)
{
    if (!context)
        return;

    kaa_client_t *kaa_client = (kaa_client_t *)context;
    kaa_error_t error;

    if (buffer) {
        if (receive_size > 0) {
            KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Kaa channel(0x%08X) receive %d bytes",
                                                                            kaa_client->channel_id, receive_size);
            error = kaa_tcp_channel_read_bytes(&kaa_client->channel, buffer, receive_size);
            if (error) {
                KAA_LOG_ERROR(kaa_client->kaa_context->logger, error, "Kaa channel error reading bytes");
            }
        }

    }
    if (receive_size == -1) {
       KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Kaa channel(0x%08X) connection termined by peer",
                                                                                               kaa_client->channel_id);
        error = kaa_client_channel_error(kaa_client);
       if (error) {
           KAA_LOG_ERROR(kaa_client->kaa_context->logger, error, "Kaa channel error dropping connection");
       }

   }
}
开发者ID:zofuthan,项目名称:kaa,代码行数:29,代码来源:esp8266_kaa_client.c


示例5: kaa_demo_add_log_record

void kaa_demo_add_log_record()
{
    ++log_record_counter;

    printf("Going to add %zuth log record\n", log_record_counter);

    kaa_user_log_record_t *log_record = kaa_logging_log_data_create();
    if (!log_record) {
        KAA_LOG_ERROR(kaa_context_->logger, KAA_ERR_NOT_INITIALIZED, "Failed to allocate log record");
        return;
    }

    log_record->level = ENUM_LEVEL_INFO;
    log_record->tag = kaa_string_move_create(KAA_DEMO_LOG_TAG, NULL);

    size_t log_message_buffer_size = strlen(KAA_DEMO_LOG_MESSAGE) + sizeof(log_record_counter);
    char log_message_buffer[log_message_buffer_size];
    snprintf(log_message_buffer, log_message_buffer_size, "%s%zu", KAA_DEMO_LOG_MESSAGE, log_record_counter);

    log_record->message = kaa_string_copy_create(log_message_buffer);

    kaa_error_t error_code = kaa_logging_add_record(kaa_context_->log_collector, log_record);
    if (error_code)
        KAA_LOG_ERROR(kaa_context_->logger, error_code, "Failed to add log record");

    log_record->destroy(log_record);
}
开发者ID:BioSoundSystems,项目名称:kaa,代码行数:27,代码来源:kaa_demo.c


示例6: kaa_client_init_channel

kaa_error_t kaa_client_init_channel(kaa_client_t *kaa_client, kaa_client_channel_type_t channel_type)
{
    KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);

    kaa_error_t error_code = KAA_ERR_NONE;

    KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Initializing channel....");

    switch (channel_type) {
        case KAA_CLIENT_CHANNEL_TYPE_BOOTSTRAP:
            error_code = kaa_tcp_channel_create(&kaa_client->channel,
                    kaa_client->kaa_context->logger,
                    BOOTSTRAP_SERVICE, BOOTSTRAP_SERVICE_COUNT);
            break;
        case KAA_CLIENT_CHANNEL_TYPE_OPERATIONS:
            error_code = kaa_tcp_channel_create(&kaa_client->channel
                                              , kaa_client->kaa_context->logger
                                              , OPERATIONS_SERVICES
                                              , OPERATIONS_SERVICES_COUNT);
            break;
    }
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Error initializing channel %d", channel_type);
        return error_code;
    }
    error_code = kaa_tcp_channel_set_keepalive_timeout(&kaa_client->channel, 120);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Error set keepalive");
    }
    error_code = kaa_channel_manager_add_transport_channel(kaa_client->kaa_context->channel_manager,
                                            &kaa_client->channel,
                                            &kaa_client->channel_id);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Error register channel %d as transport", channel_type);
        return error_code;
    }

    KAA_LOG_INFO(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Channel(type=%d,id=%08X) initialized successfully"
                                                                                , channel_type, kaa_client->channel_id);

    char *hostname = NULL;
    size_t hostname_size = 0;
    uint16_t port = 0;

    error_code = kaa_tcp_channel_get_access_point(&kaa_client->channel, &hostname, &hostname_size, &port);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Kaa tcp channel get access point failed");
    } else if (hostname_size > 0){
        char *n_hostname = strndup(hostname, hostname_size);
        KAA_LOG_INFO(kaa_client->kaa_context->logger, KAA_ERR_NONE,
                        "Channel(type=%d,id=%08X) destination %s:%d", channel_type
                        , kaa_client->channel_id, n_hostname, port);

        free(n_hostname);
    }

    return error_code;
}
开发者ID:zofuthan,项目名称:kaa,代码行数:58,代码来源:esp8266_kaa_client.c


示例7: KAA_MUTEX_LOCKING

void DefaultOperationTcpChannel::sync(TransportType type)
{
    KAA_MUTEX_LOCKING("channelGuard_");
    KAA_MUTEX_UNIQUE_DECLARE(lock, channelGuard_);
    KAA_MUTEX_LOCKED("channelGuard_");

    if (isShutdown_) {
        KAA_LOG_WARN(boost::format("Channel [%1%] can't sync: channel is shut down") % getId());
        return;
    }

    if (isPaused_) {
        KAA_LOG_WARN(boost::format("Channel [%1%] can't sync: channel is paused") % getId());
        return;
    }

    const auto& suppportedTypes = getSupportedTransportTypes();
    auto it = suppportedTypes.find(type);
    if (it == suppportedTypes.end() || it->second == ChannelDirection::DOWN) {
        KAA_LOG_ERROR(boost::format("Channel [%1%] ignore sync: unsupported transport type %2%")
                                                                        % getId()
                                                                        % LoggingUtils::toString(type));
        return;
    }

    if (!currentServer_) {
        KAA_LOG_DEBUG(boost::format("Channel [%1%] can't sync: server is null") % getId());
        return;
    }

    if (isFirstResponseReceived_) {
        KAA_MUTEX_UNLOCKING("channelGuard_");
        KAA_UNLOCK(lock);
        KAA_MUTEX_UNLOCKED("channelGuard_");

        std::map<TransportType, ChannelDirection> syncTypes;
        syncTypes.insert(std::make_pair(type, it->second));
        for (const auto& typeIt : suppportedTypes) {
            if (typeIt.first != type) {
                syncTypes.insert(std::make_pair(typeIt.first, ChannelDirection::DOWN));
            }
        }

        boost::system::error_code errorCode = sendKaaSync(syncTypes);
        if (errorCode) {
            KAA_LOG_ERROR(boost::format("Channel [%1%] failed to sync: %2%")
                                                                % getId()
                                                                % errorCode.message());
            onServerFailed();
        }
    } else {
        KAA_LOG_DEBUG(boost::format("Channel [%1%] can't sync: waiting for CONNACK + KAASYNC") % getId());
        isPendingSyncRequest_ = true;
    }
}
开发者ID:Kirill380,项目名称:kaa,代码行数:55,代码来源:DefaultOperationTcpChannel.cpp


示例8: kaa_configuration_manager_handle_server_sync

kaa_error_t kaa_configuration_manager_handle_server_sync(kaa_configuration_manager_t *self
                                                       , kaa_platform_message_reader_t *reader
                                                       , uint32_t extension_options
                                                       , size_t extension_length)
{
    KAA_RETURN_IF_NIL2(self, reader, KAA_ERR_BADPARAM);

    KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received configuration server sync: options %u, payload size %u", extension_options, extension_length);

    if (extension_length >= sizeof(uint32_t)) {
        self->status->config_seq_n = KAA_NTOHL(*((uint32_t *) reader->current));
        KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Configuration state sequence number is '%d'", self->status->config_seq_n);
        reader->current += sizeof(uint32_t);
        if (extension_options & KAA_CONFIGURATION_BODY_PRESENT) {
            uint32_t body_size = KAA_NTOHL(*((uint32_t *) reader->current));
            reader->current += sizeof(uint32_t);
            KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received configuration body, size '%u' ", body_size);
            const char* body = reader->current;
            kaa_error_t error = kaa_platform_message_skip(reader, kaa_aligned_size_get(body_size));
            if (error) {
                 KAA_LOG_ERROR(self->logger, error, "Failed to read configuration body, size %u", body_size);
                 return error;
            }

#if KAA_CONFIGURATION_DELTA_SUPPORT

#else
            if (self->root_record)
                self->root_record->destroy(self->root_record);

            self->root_record = kaa_configuration_manager_deserialize(body, body_size);
            if (!self->root_record) {
                KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to deserialize configuration body, size %u", body_size);
                return KAA_ERR_READ_FAILED;
            }

            kaa_error_t err = ext_calculate_sha_hash(body, body_size, self->configuration_hash);
            if (err) {
                KAA_LOG_WARN(self->logger, err, "Failed to calculate configuration body hash");
                return err;
            }
            ext_configuration_store(body, body_size);
#endif
            if (self->root_receiver.on_configuration_updated)
                self->root_receiver.on_configuration_updated(self->root_receiver.context, self->root_record);

            kaa_transport_channel_interface_t *channel =
                    kaa_channel_manager_get_transport_channel(self->channel_manager, configuration_sync_services[0]);
            if (channel)
                channel->sync_handler(channel->context, configuration_sync_services, 1);
        }
    }
    return KAA_ERR_NONE;
}
开发者ID:aglne,项目名称:kaa,代码行数:54,代码来源:kaa_configuration_manager.c


示例9: kaa_log_collector_init

/*
* Initializes Kaa log collector.
*/
kaa_error_t kaa_log_collector_init(kaa_client_t *kaa_client)
{
    KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM)
    kaa_error_t error_code = ext_unlimited_log_storage_create(&kaa_client->log_storage_context
                                                            , kaa_client->kaa_context->logger);

    if (error_code) {
       KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Failed to create log storage");
       return error_code;
    }

    error_code = ext_log_upload_strategy_create(kaa_client->kaa_context
                                              ,&kaa_client->log_upload_strategy_context
                                              , KAA_LOG_UPLOAD_VOLUME_STRATEGY);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Failed to create log upload strategy");
        return error_code;
    }

    // Due to unknown problems with networking via ESP8266, some server responses are lost.
    // It leads to log delivery timeouts.
    error_code = ext_log_upload_strategy_set_upload_timeout(kaa_client->log_upload_strategy_context
                                                                    , KAA_DEMO_TWO_DAYS_UPLOAD_TIMEOUT);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger,
                                                error_code,
                                                "Failed to create log upload strategy by volume set upload timeout to %d",
                                                KAA_DEMO_TWO_DAYS_UPLOAD_TIMEOUT);
        return error_code;
    }

    error_code = ext_log_upload_strategy_et_threshold_count(kaa_client->log_upload_strategy_context
                                                , KAA_DEMO_UPLOAD_COUNT_THRESHOLD);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger,
                                                error_code,
                                                "Failed to create log upload strategy by volume set threshold count to %d",
                                                KAA_DEMO_UPLOAD_COUNT_THRESHOLD);
        return error_code;
    }

    error_code = kaa_logging_init(kaa_client->kaa_context->log_collector
                                                , kaa_client->log_storage_context
                                                , kaa_client->log_upload_strategy_context);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code,"Failed to logging init");
        return error_code;
    }

    KAA_LOG_INFO(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Log collector init complete");
    return error_code;
}
开发者ID:zofuthan,项目名称:kaa,代码行数:55,代码来源:esp8266_kaa_client.c


示例10: kaa_log_collector_init

/*
 * Initializes Kaa log collector.
 */
kaa_error_t kaa_log_collector_init(kaa_client_t *kaa_client)
{
    KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);

        kaa_error_t error_code = ext_unlimited_log_storage_create(
                &kaa_client->log_storage_context,
                kaa_client->kaa_context->logger);
        if (error_code) {
            KAA_LOG_ERROR(kaa_client->kaa_context->logger,
                    error_code,
                    "Failed to create log storage");
            return error_code;
        }

        error_code = ext_log_upload_strategy_create(kaa_client->kaa_context
                                                  ,&kaa_client->log_upload_strategy_context
                                                  , KAA_LOG_UPLOAD_VOLUME_STRATEGY);

        if (error_code) {
            KAA_LOG_ERROR(kaa_client->kaa_context->logger,
                    error_code,
                    "Failed to create log upload strategy");
            return error_code;
        }

        error_code = ext_log_upload_strategy_set_threshold_count(kaa_client->log_upload_strategy_context
                                                                         , KAA_DEMO_UPLOAD_COUNT_THRESHOLD);
        if (error_code) {
            KAA_LOG_ERROR(kaa_client->kaa_context->logger,
                    error_code,
                    "Failed to create log upload strategy by volume set threshold count to %d",
                    KAA_DEMO_UPLOAD_COUNT_THRESHOLD);
            return error_code;
        }

        error_code = kaa_logging_init(kaa_client->kaa_context->log_collector
                                    , kaa_client->log_storage_context
                                    , kaa_client->log_upload_strategy_context);

        if (error_code) {
            KAA_LOG_ERROR(kaa_client->kaa_context->logger,
                    error_code,
                    "Failed to logging init");
            return error_code;
        }
        KAA_LOG_INFO(kaa_client->kaa_context->logger,
                KAA_ERR_NONE,
                "Log collector init complete");
        return error_code;

}
开发者ID:nthevu,项目名称:kaa,代码行数:54,代码来源:econais_ec19d_kaa_client.c


示例11: kaa_client_sync_serialize

static kaa_error_t kaa_client_sync_serialize(kaa_platform_protocol_t *self,
        const kaa_extension_id services[], size_t services_count, uint8_t *buffer, size_t *size)
{
    kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);

    uint16_t total_services_count = services_count + 1 /* Meta extension */;

    kaa_error_t error_code = kaa_platform_message_header_write(&writer,
            KAA_PLATFORM_PROTOCOL_ID, KAA_PLATFORM_PROTOCOL_VERSION);
    if (error_code) {
        KAA_LOG_ERROR(self->logger, error_code, "Failed to write the client sync header");
        goto fail;
    }

    uint16_t *extension_count_p = (uint16_t *)writer.current;
    writer.current += KAA_PROTOCOL_EXTENSIONS_COUNT_SIZE;
    // TODO: static assert KAA_PROTOCOL_EXTENSIONS_COUNT_SIZE == sizeof(uint16_t)

    error_code = kaa_meta_data_request_serialize(self, &writer, self->request_id);
    if (error_code) {
        goto fail;
    }

    while (!error_code && services_count--) {
        size_t size_required = writer.end - writer.current;
        bool need_resync = false;
        error_code = kaa_extension_request_serialize(services[services_count],
                self->request_id, writer.current, &size_required, &need_resync);
        if (error_code) {
            KAA_LOG_ERROR(self->logger, error_code,
                    "Failed to serialize the '%d' extension", services[services_count]);
            continue;
        }

        if (!need_resync) {
            --total_services_count;
            continue;
        }

        writer.current += size_required;
    }

    *extension_count_p = KAA_HTONS(total_services_count);
    *size = writer.current - writer.begin;

fail:
    return error_code;
}
开发者ID:Kirill380,项目名称:kaa,代码行数:48,代码来源:kaa_platform_protocol.c


示例12: kaa_client_init_channel

kaa_error_t kaa_client_init_channel(kaa_client_t *kaa_client, kaa_client_channel_type_t channel_type)
{
    KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);

    kaa_error_t error_code = KAA_ERR_NONE;

    KAA_LOG_TRACE(kaa_client->context->logger, KAA_ERR_NONE, "Initializing channel....");

    switch (channel_type) {
        case KAA_CLIENT_CHANNEL_TYPE_BOOTSTRAP:
            error_code = kaa_tcp_channel_create(&kaa_client->channel
                                              , kaa_client->context->logger
                                              , BOOTSTRAP_SERVICE
                                              , BOOTSTRAP_SERVICE_COUNT);
            break;
        case KAA_CLIENT_CHANNEL_TYPE_OPERATIONS:
            error_code = kaa_tcp_channel_create(&kaa_client->channel
                                              , kaa_client->context->logger
                                              , OPERATIONS_SERVICES
                                              , OPERATIONS_SERVICES_COUNT);
            break;
    }

    if (error_code) {
        KAA_LOG_ERROR(kaa_client->context->logger, error_code, "Failed to create transport channel, type %d", channel_type);
        return error_code;
    }

    error_code = kaa_tcp_channel_set_socket_events_callback(&kaa_client->channel, &on_kaa_tcp_channel_event, kaa_client);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->context->logger, error_code,
                "Failed to set socket events callback, channel type %d", channel_type);
        return error_code;
    }

    error_code = kaa_channel_manager_add_transport_channel(kaa_client->context->channel_manager
                                                         , &kaa_client->channel
                                                         , &kaa_client->channel_id);
    if (error_code) {
        KAA_LOG_ERROR(kaa_client->context->logger, error_code, "Failed to add transport channel, type %d", channel_type);
        return error_code;
    }

    KAA_LOG_INFO(kaa_client->context->logger, KAA_ERR_NONE, "Channel [0x%08X] initialized successfully (type %d)"
                                                                                , kaa_client->channel_id, channel_type);

    return error_code;
}
开发者ID:kaaproject,项目名称:kaa,代码行数:48,代码来源:kaa_client.c


示例13: KAA_LOG_TRACE

void DefaultOperationTcpChannel::startThreads()
{
    if (!ioThreads_.empty()) {
        return;
    }

    KAA_LOG_TRACE(boost::format("Channel [%1%] starting %2% IO service threads...")
                                                                    % getId()
                                                                    % THREADPOOL_SIZE);

    ioThreads_.reserve(THREADPOOL_SIZE);

    for (std::size_t i = 0; i < THREADPOOL_SIZE; ++i) {
        ioThreads_.emplace_back(
                [this]()
                {
                    try {
                        KAA_LOG_TRACE(boost::format("Channel [%1%] running IO service") % getId());

                        // Blocking call.
                        io_.run();

                        KAA_LOG_TRACE(boost::format("Channel [%1%] IO service stopped") % getId());
                    } catch (std::exception& e) {
                        KAA_LOG_ERROR(boost::format("Channel [%1%] unexpected stop of IO service: %2%")
                                                                                                % getId()
                                                                                                % e.what());

                        //TODO: http://jira.kaaproject.org/browse/KAA-1321
                        // Reset IO service and, perhaps, notify
                        // the channel manager about a transport failover.
                    }
                });
    }
}
开发者ID:Kirill380,项目名称:kaa,代码行数:35,代码来源:DefaultOperationTcpChannel.cpp


示例14: sendPingRequest

void DefaultOperationTcpChannel::onPingTimeout(const boost::system::error_code& err)
{
    if (!err) {
        sendPingRequest();
    } else {
        KAA_MUTEX_LOCKING("channelGuard_");
        KAA_MUTEX_UNIQUE_DECLARE(channelLock, channelGuard_);
        KAA_MUTEX_LOCKED("channelGuard_");
        if (err != boost::asio::error::operation_aborted && isConnected_) {
            KAA_MUTEX_UNLOCKING("channelGuard_");
            KAA_UNLOCK(channelLock);
            KAA_MUTEX_UNLOCKED("channelGuard_")

            KAA_LOG_ERROR(boost::format("Channel [%1%] failed to process PING: %2%") % getId() % err.message());
            onServerFailed();
            return;
        } else {
            KAA_LOG_DEBUG(boost::format("Channel [%1%] PING timer aborted") % getId());
            return;
        }
    }

    KAA_MUTEX_LOCKING("channelGuard_");
    KAA_MUTEX_UNIQUE_DECLARE(channelLock, channelGuard_);
    KAA_MUTEX_LOCKED("channelGuard_");

    if (isConnected_) {
        setPingTimer();
    }
}
开发者ID:Kirill380,项目名称:kaa,代码行数:30,代码来源:DefaultOperationTcpChannel.cpp


示例15: KAA_LOG_DEBUG

void DefaultOperationTcpChannel::onConnack(const ConnackMessage& message)
{
    KAA_LOG_DEBUG(boost::format("Channel [%1%] received Connack: status %2%")
                                                            % getId()
                                                            % message.getMessage());

    switch (message.getReturnCode()) {
        case ConnackReturnCode::ACCEPTED:
            break;
        case ConnackReturnCode::REFUSE_VERIFICATION_FAILED:
        case ConnackReturnCode::REFUSE_BAD_CREDENTIALS:
            KAA_LOG_WARN(boost::format("Channel [%1%] failed server authentication: %2%")
                                            % getId()
                                            % ConnackMessage::returnCodeToString(message.getReturnCode()));

            onServerFailed(KaaFailoverReason::ENDPOINT_NOT_REGISTERED);

            break;
        default:
            KAA_LOG_ERROR(boost::format("Channel [%1%] failed to connect to server: %2%")
                                                                    % getId()
                                                                    % message.getMessage());
            onServerFailed(KaaFailoverReason::CURRENT_OPERATIONS_SERVER_NA);
            break;
    }
}
开发者ID:Kirill380,项目名称:kaa,代码行数:26,代码来源:DefaultOperationTcpChannel.cpp


示例16: on_kaa_tcp_channel_event

kaa_error_t on_kaa_tcp_channel_event(void *context
                                                 , kaa_tcp_channel_event_t event_type
                                                 , kaa_fd_t fd)
{
    KAA_RETURN_IF_NIL(context, KAA_ERR_BADPARAM);
    kaa_client_t *self = (kaa_client_t *)context;

    switch (event_type) {
        case SOCKET_CONNECTED:
            KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE, "Bootstrap socket(%d) Connected", fd);
            if (self->bootstrap_state == BOOTSRAP_UNDEF)
                self->bootstrap_state = BOOTSRAP_STARTED;
            break;
        case SOCKET_DISCONNECTED:
            KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE, "Bootstrap socket Disconnected");
            if (self->bootstrap_state == BOOTSRAP_STARTED)
                self->bootstrap_state = BOOTSRAP_FINISHED;
            break;
        default:
            KAA_LOG_ERROR(self->kaa_context->logger, KAA_ERR_NONE, "Bootstrap socket Error");
            self->bootstrap_state = BOOTSRAP_UNDEF;
            break;
    }

    return KAA_ERR_NONE;
}
开发者ID:nthevu,项目名称:kaa,代码行数:26,代码来源:econais_ec19d_kaa_client.c


示例17: kaa_platform_protocol_alloc_serialize_client_sync

kaa_error_t kaa_platform_protocol_alloc_serialize_client_sync(kaa_platform_protocol_t *self,
        const kaa_extension_id *services, size_t services_count,
        uint8_t **buffer, size_t *buffer_size)
{
    if (!self || !buffer || !buffer_size) {
        return KAA_ERR_BADPARAM;
    }

    if (!services || services_count == 0) {
        return KAA_ERR_BADDATA;
    }

    *buffer_size = 0;
    kaa_error_t error = kaa_platform_protocol_serialize_client_sync(self, services, services_count,
            NULL, buffer_size);
    // TODO(982): assert error != KAA_ERR_NONE
    if (error != KAA_ERR_BUFFER_IS_NOT_ENOUGH) {
        return error;
    }

    *buffer = KAA_MALLOC(*buffer_size);
    if (!*buffer) {
        KAA_LOG_ERROR(self->logger, KAA_ERR_NOMEM, "No memory for buffer");
        return KAA_ERR_NOMEM;
    }

    return kaa_platform_protocol_serialize_client_sync(self, services, services_count,
            *buffer, buffer_size);
}
开发者ID:Kirill380,项目名称:kaa,代码行数:29,代码来源:kaa_platform_protocol.c


示例18: getSupportedTransportTypes

void AbstractHttpChannel::sync(TransportType type)
{
    const auto& supportedTypes = getSupportedTransportTypes();
    auto it = supportedTypes.find(type);
    if (it == supportedTypes.end() || it->second == ChannelDirection::DOWN) {
        KAA_LOG_ERROR(boost::format("Channel [%1%] unsupported transport type '%2%'")
                                                        % getId()
                                                        % LoggingUtils::toString(type));
        return;
    }

    KAA_MUTEX_LOCKING("channelGuard_");
    KAA_MUTEX_UNIQUE_DECLARE(lock, channelGuard_);
    KAA_MUTEX_LOCKED("channelGuard_");

    if (!currentServer_) {
        KAA_LOG_WARN(boost::format("Channel [%1%] can't sync: server is null") % getId());
        return;
    }

    processTypes(std::map<TransportType, ChannelDirection>({ { type, it->second } })
#ifdef KAA_THREADSAFE
               , lock
#endif
                );

}
开发者ID:Kirill380,项目名称:kaa,代码行数:27,代码来源:AbstractHttpChannel.cpp


示例19: kaa_client_sync_get_size

static kaa_error_t kaa_client_sync_get_size(kaa_platform_protocol_t *self,
        const kaa_extension_id *extensions,
        const size_t extension_count,
        size_t *expected_size)
{
    // TODO(KAA-982): Use assert here
    if (!self || !extensions || !expected_size || extension_count == 0) {
        return KAA_ERR_BADPARAM;
    }

    *expected_size = KAA_PROTOCOL_MESSAGE_HEADER_SIZE + kaa_meta_data_request_size;

    for (size_t i = 0; i < extension_count; ++i) {
        size_t extension_size = 0;

        kaa_error_t error = get_extension_request_size(extensions[i], &extension_size);
        if (error && error != KAA_ERR_NOT_FOUND) {
            KAA_LOG_ERROR(self->logger, error,
                    "Failed to query extension size for %u", extensions[i]);
            return error;
        }

        *expected_size += extension_size;
    }

    return KAA_ERR_NONE;
}
开发者ID:Kirill380,项目名称:kaa,代码行数:27,代码来源:kaa_platform_protocol.c


示例20: kaa_client_create

kaa_error_t kaa_client_create(kaa_client_t **client, kaa_client_props_t *props) {
    (void)props;
    KAA_RETURN_IF_NIL(client, KAA_ERR_BADPARAM);

    kaa_client_t *self = (kaa_client_t*)KAA_CALLOC(1, sizeof(kaa_client_t));
    KAA_RETURN_IF_NIL(self, KAA_ERR_NOMEM);
    kaa_error_t error_code = kaa_init(&self->context);

    if(error_code) {
        printf("Error initialising kaa_context\n");
        kaa_client_destroy(self);
        return error_code;
    }

    self->operate = true;

#ifndef KAA_DISABLE_FEATURE_LOGGING
    error_code = kaa_log_collector_init(self);
    if (error_code) {
        KAA_LOG_ERROR(self->context->logger, error_code, "Failed to init Kaa log collector, error %d", error_code);
        kaa_client_destroy(self);
        return error_code;
    }
#endif

    KAA_LOG_INFO(self->context->logger,KAA_ERR_NONE, "Kaa client initiallized");
    *client = self;
    return error_code;
}
开发者ID:kaaproject,项目名称:kaa,代码行数:29,代码来源:kaa_client.c



注:本文中的KAA_LOG_ERROR函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ KAA_LOG_INFO函数代码示例发布时间:2022-05-30
下一篇:
C++ K函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap