mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
add plugin names to logger instances
This commit is contained in:
parent
731909c3a8
commit
ac20c63f39
4 changed files with 39 additions and 7 deletions
|
@ -116,8 +116,9 @@ public:
|
|||
return std::string(buf);
|
||||
}
|
||||
|
||||
virtual std::string
|
||||
toString();
|
||||
|
||||
void setLogger(Logger log)
|
||||
{ logger = log; }
|
||||
};
|
||||
|
||||
class RequestFactory : public plugin::Plugin {
|
||||
|
@ -133,6 +134,11 @@ public:
|
|||
|
||||
static Request *
|
||||
create(Session *s, const std::string &uri, Session::Method meth, unsigned long ct);
|
||||
|
||||
virtual
|
||||
std::string
|
||||
getType() const
|
||||
{ return "api:request"; }
|
||||
};
|
||||
|
||||
template<typename T, const char *name, const char *re, const char *desc>
|
||||
|
@ -150,7 +156,11 @@ public:
|
|||
virtual Request *
|
||||
make(Session *s)
|
||||
{
|
||||
return new T(s);
|
||||
auto *r = new T(s);
|
||||
|
||||
r->setLogger(getLogger());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// Get plugin name
|
||||
|
|
|
@ -40,6 +40,8 @@ protected:
|
|||
|
||||
bool destroy_signals;
|
||||
|
||||
Logger logger;
|
||||
|
||||
struct {
|
||||
char *buffer;
|
||||
size_t buflen;
|
||||
|
@ -59,7 +61,8 @@ public:
|
|||
int getFlags() const
|
||||
{ return flags; }
|
||||
|
||||
virtual ~Format();
|
||||
void setLogger(Logger log)
|
||||
{ logger = log; }
|
||||
|
||||
void start(struct vlist *sigs, int fl = (int) SampleFlags::HAS_ALL);
|
||||
void start(const std::string &dtypes, int fl = (int) SampleFlags::HAS_ALL);
|
||||
|
@ -142,6 +145,10 @@ public:
|
|||
|
||||
static
|
||||
Format * make(const std::string &format);
|
||||
|
||||
virtual
|
||||
std::string getType() const
|
||||
{ return "format"; }
|
||||
};
|
||||
|
||||
template <typename T, const char *name, const char *desc, int flags = 0>
|
||||
|
@ -152,7 +159,11 @@ public:
|
|||
|
||||
virtual Format * make()
|
||||
{
|
||||
return new T(flags);
|
||||
auto *f = new T(flags);
|
||||
|
||||
f->setLogger(getLogger());
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/// Get plugin name
|
||||
|
|
|
@ -81,6 +81,9 @@ public:
|
|||
virtual void parse(json_t *c);
|
||||
void prepare(struct vlist *sigs);
|
||||
|
||||
void setLogger(Logger log)
|
||||
{ logger = log; }
|
||||
|
||||
/** Called whenever a hook is started; before threads are created. */
|
||||
virtual void start()
|
||||
{
|
||||
|
@ -183,6 +186,11 @@ public:
|
|||
|
||||
virtual int getFlags() const = 0;
|
||||
virtual int getPriority() const = 0;
|
||||
|
||||
virtual
|
||||
std::string
|
||||
getType() const
|
||||
{ return "hook"; }
|
||||
};
|
||||
|
||||
template <typename T, const char *name, const char *desc, int flags = 0, int prio = 99>
|
||||
|
@ -193,7 +201,11 @@ public:
|
|||
|
||||
virtual Hook * make(struct vpath *p, struct vnode *n)
|
||||
{
|
||||
return new T(p, n, getFlags(), getPriority());
|
||||
auto *h = new T(p, n, getFlags(), getPriority());
|
||||
|
||||
h->setLogger(getLogger());
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
/// Get plugin name
|
||||
|
|
|
@ -39,7 +39,6 @@ using namespace villas;
|
|||
using namespace villas::node;
|
||||
|
||||
Hook::Hook(struct vpath *p, struct vnode *n, int fl, int prio, bool en) :
|
||||
logger(logging.get("hook")),
|
||||
state(State::INITIALIZED),
|
||||
flags(fl),
|
||||
priority(prio),
|
||||
|
|
Loading…
Add table
Reference in a new issue