diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-12-12 15:19:14 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-12-12 15:19:14 (GMT) |
commit | 047a35fc691a348008cbfbf4c3d7722a6ec4f93e (patch) | |
tree | 362a55496c4185b0be5966073d43d00e1b0e27de /src/uscxml/plugins/invoker | |
parent | dcac58f473789dd07e9094e61f819aef2fbc4b4a (diff) | |
download | uscxml-047a35fc691a348008cbfbf4c3d7722a6ec4f93e.zip uscxml-047a35fc691a348008cbfbf4c3d7722a6ec4f93e.tar.gz uscxml-047a35fc691a348008cbfbf4c3d7722a6ec4f93e.tar.bz2 |
Custom logging for interpreters
Diffstat (limited to 'src/uscxml/plugins/invoker')
-rw-r--r-- | src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp | 11 | ||||
-rw-r--r-- | src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h | 5 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp index de5994a..d6d0f99 100644 --- a/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp +++ b/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.cpp @@ -99,7 +99,7 @@ void DirMonInvoker::eventFromSCXML(const Event& event) { void DirMonInvoker::invoke(const std::string& source, const Event& req) { if (req.params.find("dir") == req.params.end()) { - LOG(USCXML_ERROR) << "No dir param given"; + LOG(_interpreter->getLogger(), USCXML_ERROR) << "No dir param given"; return; } @@ -137,7 +137,7 @@ void DirMonInvoker::invoke(const std::string& source, const Event& req) { URL url = URL::resolve(dirIter->second.atom, _interpreter->getBaseURL()); if (!url.isAbsolute()) { - LOG(USCXML_ERROR) << "Given directory '" << dirIter->second << "' cannot be transformed to absolute path"; + LOG(_interpreter->getLogger(), USCXML_ERROR) << "Given directory '" << dirIter->second << "' cannot be transformed to absolute path"; } else { _dir = url.path(); } @@ -145,6 +145,7 @@ void DirMonInvoker::invoke(const std::string& source, const Event& req) { } _watcher = new DirectoryWatch(_dir, _recurse); + _watcher->setLogger(_interpreter->getLogger()); _watcher->addMonitor(this); _watcher->updateEntries(true); @@ -313,7 +314,7 @@ void DirectoryWatch::updateEntries(bool reportAsExisting) { // stat directory for modification date struct stat dirStat; if (stat((_dir + _relDir).c_str(), &dirStat) != 0) { - LOG(USCXML_ERROR) << "Error with stat on directory " << _dir << ": " << strerror(errno); + LOG(_logger, USCXML_ERROR) << "Error with stat on directory " << _dir << ": " << strerror(errno); return; } @@ -327,7 +328,7 @@ void DirectoryWatch::updateEntries(bool reportAsExisting) { DIR *dp; dp = opendir((_dir + _relDir).c_str()); if (dp == NULL) { - LOG(USCXML_ERROR) << "Error opening directory " << _dir + _relDir << ": " << strerror(errno); + LOG(_logger, USCXML_ERROR) << "Error opening directory " << _dir + _relDir << ": " << strerror(errno); return; } // iterate all entries and see what changed @@ -352,7 +353,7 @@ void DirectoryWatch::updateEntries(bool reportAsExisting) { struct stat fileStat; if (stat(filename.c_str(), &fileStat) != 0) { - LOG(USCXML_ERROR) << "Error with stat on directory entry: " << filename << ": " << strerror(errno); + LOG(_logger, USCXML_ERROR) << "Error with stat on directory entry: " << filename << ": " << strerror(errno); continue; } diff --git a/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h b/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h index 6e13864..e6bb9aa 100644 --- a/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h +++ b/src/uscxml/plugins/invoker/dirmon/DirMonInvoker.h @@ -73,11 +73,16 @@ public: return entries; } + void setLogger(Logger logger) { + _logger = logger; + } + protected: DirectoryWatch(const std::string& dir, const std::string& relDir) : _dir(dir), _relDir(relDir), _recurse(true), _lastChecked(0) {} std::string _dir; std::string _relDir; + Logger _logger; bool _recurse; std::map<std::string, struct stat> _knownEntries; |