From 0374b80dd407d7b35654a01e3c7526b749d3464e Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 23 Dec 2022 17:18:42 +0100 Subject: Just-MR: Remove wrong pass-by-reference when wrapping loggers Passing the logger by reference would require the caller to be kept alive. Also, being a shared_ptr, the logger can be passed by value at almost no cost. --- src/other_tools/git_operations/git_operations.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/other_tools/git_operations/git_operations.cpp') diff --git a/src/other_tools/git_operations/git_operations.cpp b/src/other_tools/git_operations/git_operations.cpp index 2b519691..bf6b29b3 100644 --- a/src/other_tools/git_operations/git_operations.cpp +++ b/src/other_tools/git_operations/git_operations.cpp @@ -34,7 +34,7 @@ auto CriticalGitOps::GitInitialCommit(GitOpParams const& crit_op_params, } // setup wrapped logger auto wrapped_logger = std::make_shared( - [&logger](auto const& msg, bool fatal) { + [logger](auto const& msg, bool fatal) { (*logger)( fmt::format("While doing initial commit Git op:\n{}", msg), fatal); @@ -95,7 +95,7 @@ auto CriticalGitOps::GitKeepTag(GitOpParams const& crit_op_params, } // setup wrapped logger auto wrapped_logger = std::make_shared( - [&logger](auto const& msg, bool fatal) { + [logger](auto const& msg, bool fatal) { (*logger)(fmt::format("While doing keep tag Git op:\n{}", msg), fatal); }); @@ -129,7 +129,7 @@ auto CriticalGitOps::GitGetHeadId(GitOpParams const& crit_op_params, } // setup wrapped logger auto wrapped_logger = std::make_shared( - [&logger](auto const& msg, bool fatal) { + [logger](auto const& msg, bool fatal) { (*logger)(fmt::format("While doing get HEAD id Git op:\n{}", msg), fatal); }); @@ -162,7 +162,7 @@ auto CriticalGitOps::GitGetBranchRefname( } // setup wrapped logger auto wrapped_logger = std::make_shared( - [&logger](auto const& msg, bool fatal) { + [logger](auto const& msg, bool fatal) { (*logger)( fmt::format("While doing get branch refname Git op:\n{}", msg), fatal); -- cgit v1.2.3