Skip to content

Commit 05a3d03

Browse files
authored
BugFix: fixed the issue of coredump caused by redundant initialization of logs in the HTTPS example (#68)
1 parent a73c1c2 commit 05a3d03

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

examples/features/https/client/client.cc

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ int main(int argc, char* argv[]) {
197197
exit(-1);
198198
}
199199

200-
::trpc::log::Init();
201200
// If the business code is running in trpc pure client mode,
202201
// the business code needs to be running in the `RunInTrpcRuntime` function
203202
return ::trpc::RunInTrpcRuntime([]() { return http::demo::Run(); });

trpc/util/log/logging.h

+12-6
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,16 @@ constexpr char kTrpcLogCacheStringDefault[] = "default";
196196
TRPC_PRT_IF_EX(context, instance, condition, ::trpc::Log::critical, format, ##args)
197197

198198
/// @brief Log will be output to the "default" logger instance provided by the framework "default" plugin.
199-
#define TRPC_PRT_TRACE(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::trace, format, ##args)
200-
#define TRPC_PRT_DEBUG(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::debug, format, ##args)
201-
#define TRPC_PRT_INFO(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::info, format, ##args)
202-
#define TRPC_PRT_WARN(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::warn, format, ##args)
203-
#define TRPC_PRT_ERROR(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::error, format, ##args)
199+
#define TRPC_PRT_TRACE(format, args...) \
200+
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::trace, format, ##args)
201+
#define TRPC_PRT_DEBUG(format, args...) \
202+
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::debug, format, ##args)
203+
#define TRPC_PRT_INFO(format, args...) \
204+
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::info, format, ##args)
205+
#define TRPC_PRT_WARN(format, args...) \
206+
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::warn, format, ##args)
207+
#define TRPC_PRT_ERROR(format, args...) \
208+
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::error, format, ##args)
204209
#define TRPC_PRT_CRITICAL(format, args...) \
205210
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::critical, format, ##args)
206211

@@ -247,7 +252,8 @@ constexpr char kTrpcLogCacheStringDefault[] = "default";
247252
#define TRPC_LOGGER_INFO_IF(instance, condition, msg) TRPC_LOG_MSG_IF(::trpc::Log::info, instance, condition, msg)
248253
#define TRPC_LOGGER_WARN_IF(instance, condition, msg) TRPC_LOG_MSG_IF(::trpc::Log::warn, instance, condition, msg)
249254
#define TRPC_LOGGER_ERROR_IF(instance, condition, msg) TRPC_LOG_MSG_IF(::trpc::Log::error, instance, condition, msg)
250-
#define TRPC_LOGGER_CRITICAL_IF(instance, condition, msg) TRPC_LOG_MSG_IF(::trpc::Log::critical, instance, condition, msg)
255+
#define TRPC_LOGGER_CRITICAL_IF(instance, condition, msg) \
256+
TRPC_LOG_MSG_IF(::trpc::Log::critical, instance, condition, msg)
251257

252258
/// @brief logger instances can be specified to customize the log output.
253259
/// @note Use case: Separate business logs from framework logs,

trpc/util/object_pool/object_pool.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ enum class ObjectPoolType {
3737
kGlobal
3838
};
3939

40-
/// @brief The internal encapsulated implementation of object_pool. Do not use the interfaces of this namespace directly.
40+
/// @brief The internal encapsulated implementation of object_pool. Do not use the interfaces of this namespace
41+
/// directly.
4142
/// @private For internal use purpose only.
4243
namespace detail {
4344

0 commit comments

Comments
 (0)