Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
src: implement per-process native Debug() printer
This patch adds a per-process native Debug() printer that can be
called when an Environment is not available.
  • Loading branch information
joyeecheung committed Feb 20, 2020
commit ce2d7fe701efcaf1282e858b27b03a4e9087eb51
15 changes: 14 additions & 1 deletion src/debug_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,20 @@ class NativeSymbolDebuggingContext {
void CheckedUvLoopClose(uv_loop_t* loop);
void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream);

} // namespace node
namespace per_process {
extern std::shared_ptr<EnabledDebugList> enabled_debug_list;

template <typename... Args>
inline void FORCE_INLINE Debug(DebugCategory cat,
const char* format,
Args&&... args) {
Debug(enabled_debug_list.get(), cat, format, std::forward<Args>(args)...);
}

inline void FORCE_INLINE Debug(DebugCategory cat, const char* message) {
Debug(enabled_debug_list.get(), cat, message);
}
} // namespace per_process

#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

Expand Down
2 changes: 2 additions & 0 deletions src/node_env_var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class MapKVStore final : public KVStore {
namespace per_process {
Mutex env_var_mutex;
std::shared_ptr<KVStore> system_environment = std::make_shared<RealEnvStore>();
std::shared_ptr<EnabledDebugList> enabled_debug_list =
std::make_shared<EnabledDebugList>(nullptr);
Comment thread
addaleax marked this conversation as resolved.
Outdated
} // namespace per_process

template <typename T>
Expand Down