PlanetKit initialization and log setting
You must initialize PlanetKit before using any functions of LINE Planet in your application. This page provides a code example for initializing PlanetKit and configuring log settings.
Initialization
Initialize PlanetKit using PlanetKitManager::Initialize() with a Configuration object. After that, you must set planet_base_url through UpdateServerUrl().
You can find planet_base_url for each environment in Development environment.
void YourApplication::InitializePlanetKit(bool bLogSizeUnlimited, PlanetKit::ELogLevel eLogLevel, PlanetKit::ELogSizeLimit eLogSizeLimit = PlanetKit::ELogSizeLimit::PLNK_LOG_SIZE_LIMIT_LARGE)
{
PlanetKit::WString strLogPath(L"your_log_path");
PlanetKit::ConfigurationPtr pConfiguration = PlanetKit::Configuration::Create(L"./");
if(bLogSizeUnlimited) {
pConfiguration->EnableLog(strLogPath, L"your_log_file_name", eLogLevel);
}
else {
pConfiguration->EnableLog(strLogPath, eLogLevel, eLogSizeLimit);
}
PlanetKit::PlanetKitManager::Initialize(pConfiguration);
PlanetKit::PlanetKitManagerPtr pPlanetKitManager = PlanetKit::PlanetKitManager::GetInstance();
pPlanetKitManager->UpdateServerUrl(planet_base_url);
}
Log setting
If you need to debug, you must configure logging using EnableLog() of the Configuration class during initialization. PlanetKit provides two EnableLog() methods for flexible log configuration.
- By default, the logging is disabled.
- Starting with PlanetKit 5.1, logs can be output to files only.
Log levels
You can adjust the level of debug information output by setting the log level. Log level settings available in in the ELogLevel enum are as follows:
PLNK_LOG_SIMPLE: PlanetKit outputs simple debug information.PLNK_LOG_DETAILED: PlanetKit outputs detailed debug information.
To request debugging from the LINE Planet team, you must send a log file created with the PLNK_LOG_DETAILED level.
Configure logging with size limit
To configure logging with automatic rotation when the size limit is reached, use the EnableLog(strLogDirectory, eLogLevel, eLogSizeLimit) method.
- Log file name
- Log files are created according to internal logic, with rotation applied (for example,
planetkit.log,planetkit.log.1,planetkit.log.2).
- Log files are created according to internal logic, with rotation applied (for example,
- Log level
- The default value of the
eLogLevelparameter isPLNK_LOG_SIMPLE.
- The default value of the
- Log size limit
- Log size limit settings available in
ELogSizeLimitare as follows:PLNK_LOG_SIZE_LIMIT_SMALL: The total size limit of log files is 16MB.PLNK_LOG_SIZE_LIMIT_MEDIUM: The total size limit of log files is 64MB.PLNK_LOG_SIZE_LIMIT_LARGE: The total size limit of log files is 256MB.
- The default value of the
eLogSizeLimitparameter isPLNK_LOG_SIZE_LIMIT_LARGE.
- Log size limit settings available in
The following is an example of configuring logging with size limit.
void YourApplication::InitializePlanetKitWithSizeLimit(PlanetKit::ELogLevel eLogLevel, PlanetKit::ELogSizeLimit eLogSizeLimit = PlanetKit::ELogSizeLimit::PLNK_LOG_SIZE_LIMIT_LARGE)
{
PlanetKit::WString strLogPath(L"your_log_path");
PlanetKit::ConfigurationPtr pConfiguration = PlanetKit::Configuration::Create(L"./");
pConfiguration->EnableLog(strLogPath, eLogLevel, eLogSizeLimit);
PlanetKit::PlanetKitManager::Initialize(pConfiguration);
PlanetKit::PlanetKitManagerPtr pPlanetKitManager = PlanetKit::PlanetKitManager::GetInstance();
pPlanetKitManager->UpdateServerUrl(planet_base_url);
}
Configure logging without size limit
To configure logging without a size limit, use the EnableLog(strLogDirectory, strLogFileName, eLogLevel) method.
- Log file name
- The default format of the log file created by the system is
planetkitMMDD_HHMMSS.log, which includes a timestamp. - Optionally, you can set a custom file name in the
strLogFileNameparameter.
- The default format of the log file created by the system is
- Log level
- The default value of the
eLogLevelparameter isPLNK_LOG_SIMPLE.
- The default value of the
The following is an example of configuring logging without size limit.
void YourApplication::InitializePlanetKitWithoutSizeLimit(PlanetKit::ELogLevel eLogLevel)
{
PlanetKit::WString strLogPath(L"your_log_path");
PlanetKit::ConfigurationPtr pConfiguration = PlanetKit::Configuration::Create(L"./");
pConfiguration->EnableLog(strLogPath, L"your_log_file_name", eLogLevel);
PlanetKit::PlanetKitManager::Initialize(pConfiguration);
PlanetKit::PlanetKitManagerPtr pPlanetKitManager = PlanetKit::PlanetKitManager::GetInstance();
pPlanetKitManager->UpdateServerUrl(planet_base_url);
}