diff --git a/log/src/Logger.cc b/log/src/Logger.cc index e0d1824..2d04869 100644 --- a/log/src/Logger.cc +++ b/log/src/Logger.cc @@ -14,6 +14,8 @@ * limitations under the License. * */ +#include +#include #include #include @@ -85,11 +87,18 @@ void Logger::SetLogDestination(const std::string &_filename) if (!_filename.empty()) { - this->dataPtr->fileSink = - std::make_shared(_filename, true); - this->dataPtr->fileSink->set_formatter(this->dataPtr->formatter->clone()); - this->dataPtr->fileSink->set_level(spdlog::level::trace); - this->dataPtr->sinks->add_sink(this->dataPtr->fileSink); + try + { + this->dataPtr->fileSink = + std::make_shared(_filename, true); + this->dataPtr->fileSink->set_formatter(this->dataPtr->formatter->clone()); + this->dataPtr->fileSink->set_level(spdlog::level::trace); + this->dataPtr->sinks->add_sink(this->dataPtr->fileSink); + } + catch(const std::exception &_e) + { + std::cerr << "Error creating log file: " << _e.what() << std::endl; + } } }