Skip to content

Commit

Permalink
BugFix: fixed the issue of coredump caused by redundant initializatio…
Browse files Browse the repository at this point in the history
…n of logs in the HTTPS example (#68)
  • Loading branch information
bochencwx authored Oct 27, 2023
1 parent a73c1c2 commit 05a3d03
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 0 additions & 1 deletion examples/features/https/client/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ int main(int argc, char* argv[]) {
exit(-1);
}

::trpc::log::Init();
// If the business code is running in trpc pure client mode,
// the business code needs to be running in the `RunInTrpcRuntime` function
return ::trpc::RunInTrpcRuntime([]() { return http::demo::Run(); });
Expand Down
18 changes: 12 additions & 6 deletions trpc/util/log/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,16 @@ constexpr char kTrpcLogCacheStringDefault[] = "default";
TRPC_PRT_IF_EX(context, instance, condition, ::trpc::Log::critical, format, ##args)

/// @brief Log will be output to the "default" logger instance provided by the framework "default" plugin.
#define TRPC_PRT_TRACE(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::trace, format, ##args)
#define TRPC_PRT_DEBUG(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::debug, format, ##args)
#define TRPC_PRT_INFO(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::info, format, ##args)
#define TRPC_PRT_WARN(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::warn, format, ##args)
#define TRPC_PRT_ERROR(format, args...) TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::error, format, ##args)
#define TRPC_PRT_TRACE(format, args...) \
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::trace, format, ##args)
#define TRPC_PRT_DEBUG(format, args...) \
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::debug, format, ##args)
#define TRPC_PRT_INFO(format, args...) \
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::info, format, ##args)
#define TRPC_PRT_WARN(format, args...) \
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::warn, format, ##args)
#define TRPC_PRT_ERROR(format, args...) \
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::error, format, ##args)
#define TRPC_PRT_CRITICAL(format, args...) \
TRPC_PRT_DEFAULT(::trpc::log::kTrpcLogCacheStringDefault, ::trpc::Log::critical, format, ##args)

Expand Down Expand Up @@ -247,7 +252,8 @@ constexpr char kTrpcLogCacheStringDefault[] = "default";
#define TRPC_LOGGER_INFO_IF(instance, condition, msg) TRPC_LOG_MSG_IF(::trpc::Log::info, instance, condition, msg)
#define TRPC_LOGGER_WARN_IF(instance, condition, msg) TRPC_LOG_MSG_IF(::trpc::Log::warn, instance, condition, msg)
#define TRPC_LOGGER_ERROR_IF(instance, condition, msg) TRPC_LOG_MSG_IF(::trpc::Log::error, instance, condition, msg)
#define TRPC_LOGGER_CRITICAL_IF(instance, condition, msg) TRPC_LOG_MSG_IF(::trpc::Log::critical, instance, condition, msg)
#define TRPC_LOGGER_CRITICAL_IF(instance, condition, msg) \
TRPC_LOG_MSG_IF(::trpc::Log::critical, instance, condition, msg)

/// @brief logger instances can be specified to customize the log output.
/// @note Use case: Separate business logs from framework logs,
Expand Down
3 changes: 2 additions & 1 deletion trpc/util/object_pool/object_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ enum class ObjectPoolType {
kGlobal
};

/// @brief The internal encapsulated implementation of object_pool. Do not use the interfaces of this namespace directly.
/// @brief The internal encapsulated implementation of object_pool. Do not use the interfaces of this namespace
/// directly.
/// @private For internal use purpose only.
namespace detail {

Expand Down

0 comments on commit 05a3d03

Please sign in to comment.