diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-08-11 23:41:26 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-08-12 01:47:32 +0100 |
commit | 31f61cdaa796957f703d3374ec5cec7e897fecbc (patch) | |
tree | 7dd56a6e221c5ee63cb56ae92d3638f0d64acafe | |
parent | Visibility hidden (diff) | |
download | netfs-31f61cdaa796957f703d3374ec5cec7e897fecbc.tar.bz2 netfs-31f61cdaa796957f703d3374ec5cec7e897fecbc.tar.xz netfs-31f61cdaa796957f703d3374ec5cec7e897fecbc.zip |
Write client logs to syslog instead of stderr (/dev/null)
-rw-r--r-- | libfusepp/fuseAppBase.cpp | 2 | ||||
-rw-r--r-- | libfusepp/fuseAppBase.h | 5 | ||||
-rw-r--r-- | netfs/fuse/Jamfile.jam | 4 | ||||
-rw-r--r-- | netfs/fuse/netfs.cpp | 17 | ||||
-rw-r--r-- | netfs/unittests/Jamfile.jam | 3 | ||||
-rw-r--r-- | netfs/unittests/mockFuse.cpp | 7 | ||||
-rw-r--r-- | netfs/unittests/mockFuse.h | 1 |
7 files changed, 36 insertions, 3 deletions
diff --git a/libfusepp/fuseAppBase.cpp b/libfusepp/fuseAppBase.cpp index 49f2d6b..b56b765 100644 --- a/libfusepp/fuseAppBase.cpp +++ b/libfusepp/fuseAppBase.cpp @@ -184,7 +184,7 @@ int FuseAppBase::fallocate(const char *, int, off_t, off_t, struct fuse_file_inf } int FuseAppBase::onError(const std::exception & e) throw() { - fprintf(stderr, "Unknown exception (what: %s)\n", e.what()); + log(LOG_ERR, stringf("Unknown exception (what: %s)\n", e.what())); return -ENOSYS; } diff --git a/libfusepp/fuseAppBase.h b/libfusepp/fuseAppBase.h index 1a4a0bc..a9be11b 100644 --- a/libfusepp/fuseAppBase.h +++ b/libfusepp/fuseAppBase.h @@ -7,6 +7,8 @@ #include <exception> #include <stdio.h> #include <errno.h> +#include <syslog.h> +#include <misc.h> #ifndef DLL_PUBLIC #define DLL_PUBLIC __attribute__ ((visibility ("default"))) #endif @@ -58,6 +60,7 @@ class DLL_PUBLIC FuseAppBase { virtual int flock(const char *, struct fuse_file_info *, int op); virtual int fallocate(const char *, int, off_t, off_t, struct fuse_file_info *); virtual int onError(const std::exception & err) throw(); + virtual void log(int level, const std::string &) const throw() = 0; virtual int fuse_opt_parse(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc) = 0; virtual int main(int, char **, const struct fuse_operations *) = 0; @@ -156,7 +159,7 @@ class DLL_PUBLIC FuseAppBase { return helper<f>(a...); } catch (...) { - fprintf(stderr, "Unknown exception calling %s\n", typeid(f).name()); + fuseApp->log(LOG_ERR, stringf("Unknown exception calling %s\n", typeid(f).name())); return -ENOSYS; } } diff --git a/netfs/fuse/Jamfile.jam b/netfs/fuse/Jamfile.jam index 142221e..8413d1f 100644 --- a/netfs/fuse/Jamfile.jam +++ b/netfs/fuse/Jamfile.jam @@ -29,8 +29,11 @@ lib netfsClientConfiguration : <library>..//slicer ; +obj misc : ../../libmisc/misc.cpp ; + lib netfsClient : pch + misc netfsClientConfiguration [ glob *.cpp : netfs.cpp ] [ glob ../../libfusepp/fuse*.cpp ] @@ -66,6 +69,7 @@ lib netfsClient : ; exe netfs : + misc netfs.cpp : <library>netfsClient <library>fuse diff --git a/netfs/fuse/netfs.cpp b/netfs/fuse/netfs.cpp index 23996c2..945c599 100644 --- a/netfs/fuse/netfs.cpp +++ b/netfs/fuse/netfs.cpp @@ -1,8 +1,18 @@ #include "fuseApp.h" +#include <syslog.h> class FuseImpl : public NetFS::FuseApp { public: - FuseImpl(const Ice::StringSeq & a) : NetFS::FuseApp(a) { } + FuseImpl(const Ice::StringSeq & a) : + NetFS::FuseApp(a) + { + openlog("netfs", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + } + + ~FuseImpl() + { + closelog(); + } struct fuse_context * fuse_get_context() override { @@ -18,6 +28,11 @@ class FuseImpl : public NetFS::FuseApp { { return ::fuse_main(argc, argv, ops, this); } + + void log(int priority, const std::string & message) const throw() override + { + syslog(priority, "%s", message.c_str()); + } }; int diff --git a/netfs/unittests/Jamfile.jam b/netfs/unittests/Jamfile.jam index 74275c5..9aa8bda 100644 --- a/netfs/unittests/Jamfile.jam +++ b/netfs/unittests/Jamfile.jam @@ -9,6 +9,7 @@ lib Ice ; path-constant me : . ; lib testMocks : + ../../libmisc/misc.cpp [ glob mock*.cpp ] : <library>IceUtil @@ -18,6 +19,8 @@ lib testMocks : <library>../daemon//netfsd <library>../fuse//netfsClient <library>../ice//netfsComms + <define>BOOST_TEST_DYN_LINK + <library>boost_utf <define>ROOT=\"$(me)\" : : <library>boost_system diff --git a/netfs/unittests/mockFuse.cpp b/netfs/unittests/mockFuse.cpp index a9e2cc1..4b92332 100644 --- a/netfs/unittests/mockFuse.cpp +++ b/netfs/unittests/mockFuse.cpp @@ -1,4 +1,5 @@ #include "mockFuse.h" +#include <boost/test/test_tools.hpp> FuseMock::FuseMock(const std::string & ep, const Ice::StringSeq & a) : NetFS::FuseApp(a), @@ -45,6 +46,12 @@ FuseMock::ReadConfiguration(const std::string & path) const return c; } +void +FuseMock::log(int, const std::string & message) const throw() +{ + BOOST_MESSAGE(message); +} + FuseMockHost::FuseMockHost(const std::string & ep, const Ice::StringSeq & a) : app(new FuseMock(ep, a)), fuse(&app->ops) diff --git a/netfs/unittests/mockFuse.h b/netfs/unittests/mockFuse.h index e28fd5a..71b1c5e 100644 --- a/netfs/unittests/mockFuse.h +++ b/netfs/unittests/mockFuse.h @@ -10,6 +10,7 @@ class FuseMock : public NetFS::FuseApp { struct fuse_context * fuse_get_context() override; int fuse_opt_parse(struct fuse_args * args, void * data, const struct fuse_opt [], fuse_opt_proc_t proc) override; int main(int, char **, const struct fuse_operations * o) override; + void log(int, const std::string &) const throw() override; fuse_operations ops; |