Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef INLONG_SDK_CONSTANT_H
#define INLONG_SDK_CONSTANT_H

#include "string.h"
#include <stdint.h>

namespace inlong {
namespace constants {
static const int32_t kMaxRequestTDMTimes = 4;
static const char kAttrFormat[] =
"__addcol1__reptime=yyyymmddHHMMSS&__addcol2_ip=xxx.xxx.xxx.xxx";
static const int32_t kAttrLen = strlen(kAttrFormat);

static const char kVersion[] = "inlong-sdk-cpp-v3.2";
static const uint16_t kBinaryMagic = 0xEE01;
static const uint32_t kBinPackMethod = 7;
static const uint8_t kBinSnappyFlag = 1 << 5;

static const int32_t kPerGroupidThreadNums = 1;
static const int32_t kSendBufSize = 10240000;
static const int32_t kRecvBufSize = 10240000;

static const int32_t kDispatchIntervalZip = 8;
static const int32_t kDispatchIntervalSend = 10;

static const bool kEnablePack = true;
static const uint32_t kPackSize = 409600;
static const uint32_t kPackTimeout = 3000;
static const uint32_t kExtPackSize = 409600;

static const bool kEnableZip = true;
static const uint32_t kMinZipLen = 512;

static const uint32_t kLogNum = 5;
static const uint32_t kLogSize = 100 * 1024 * 1024;
static const uint8_t kLogLevel = 2;
static const char kLogPath[] = "./";

static const char kBusURL[] = "127.0.0.1/api/tdbus_ip_v2";
static const bool kEnableBusURLFromCluster = false;
static const char kBusClusterURL[] =
"127.0.0.1/heartbeat/tdbus_ip_v2?cluster_id=0&net_tag=all";
static const uint32_t kBusUpdateInterval = 2;
static const uint32_t kBusURLTimeout = 5;
static const uint32_t kMaxBusNum = 200;

static const bool kEnableTCPNagle = true;
static const uint32_t kTcpIdleTime = 600000;
static const uint32_t kTcpDetectionInterval = 60000;

static const char kSerIP[] = "127.0.0.1";
static const uint32_t kSerPort = 46801;
static const uint32_t kMsgType = 7;

static const bool kEnableSetAffinity = false;
static const uint32_t kMaskCPUAffinity = 0xff;
static const uint16_t kExtendField = 0;

} // namespace constants
} // namespace inlong
#endif // INLONG_SDK_CONSTANT_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#pragma once
#ifndef INLONG_SDK_LOGGER_H
#define INLONG_SDK_LOGGER_H

#include "sdk_conf.h"
#include <log4cplus/fileappender.h>
#include <log4cplus/helpers/loglog.h>
#include <log4cplus/initializer.h>
#include <log4cplus/log4cplus.h>
#include <log4cplus/logger.h>
#include <log4cplus/loglevel.h>
using namespace log4cplus::helpers;

namespace inlong {
static void initLog4cplus() {
std::string log_path = SdkConfig::getInstance()->log_path_;
if (log_path.back() != '/') {
log_path = "./inlong-sdk-logs/";
}
std::string log_name = log_path + "/inlong-sdk.log";
log4cplus::SharedAppenderPtr the_append(new log4cplus::RollingFileAppender(
log_name, SdkConfig::getInstance()->log_size_,
SdkConfig::getInstance()->log_num_));
log4cplus::tstring pattern =
LOG4CPLUS_TEXT("%D{%m-%d %H:%M:%S:%Q} %m [%b:%L]\n");
the_append->setLayout(
std::auto_ptr<log4cplus::Layout>(new log4cplus::PatternLayout(pattern)));
switch (SdkConfig::getInstance()->log_level_) {
case 0:
log4cplus::Logger::getRoot().setLogLevel(log4cplus::ERROR_LOG_LEVEL);
break;
case 1:
log4cplus::Logger::getRoot().setLogLevel(log4cplus::WARN_LOG_LEVEL);
break;
case 2:
log4cplus::Logger::getRoot().setLogLevel(log4cplus::INFO_LOG_LEVEL);
break;
case 3:
log4cplus::Logger::getRoot().setLogLevel(log4cplus::DEBUG_LOG_LEVEL);
break;
default:
log4cplus::Logger::getRoot().setLogLevel(log4cplus::INFO_LOG_LEVEL);
break;
}

log4cplus::Logger::getRoot().addAppender(the_append);
}

#define LOG_ERROR(x) \
{ \
std::stringstream _log_ss; \
_log_ss << "ERROR " << x; \
LOG4CPLUS_ERROR(log4cplus::Logger::getRoot(), _log_ss.str()); \
}

#define LOG_WARN(x) \
{ \
std::stringstream _log_ss; \
_log_ss << "WARN " << x; \
LOG4CPLUS_WARN(log4cplus::Logger::getRoot(), _log_ss.str()); \
}

#define LOG_INFO(x) \
{ \
std::stringstream _log_ss; \
_log_ss << "INFO " << x; \
LOG4CPLUS_INFO(log4cplus::Logger::getRoot(), _log_ss.str()); \
}

#define LOG_DEBUG(x) \
{ \
std::stringstream _log_ss; \
_log_ss << "DEBUG " << x; \
LOG4CPLUS_DEBUG(log4cplus::Logger::getRoot(), _log_ss.str()); \
}

} // namespace inlong
#endif // INLONG_SDK_LOGGER_H