You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently Quill copies all user defined types and then formats them on a backend thread. This leads problems when user defined types include a mutable reference or pointer to another object.
I am thinking to have two modes available. It should be able to switch between them with a preprocessor definition.
Safe Logging
If this mode is used without providing a tag to all the safe objects it will degrade performance.
However, if used correctly it can achieve the same performance as unsafe logging in a safer way.
This mode will copy all safe to copy types that accepted by printf to the spsc queue and format them later on the backend logger thread.
For any user defined types check if copy_loggable_t tag is defined and copy the object without formatting, otherwise if the tag is not defined fallback to calling operator<< on the caller thread.
For all related stl objects and containers check the underlying type against 1) and 2) and decide whether to copy or format the container on the caller thread.
example :
class foo
{
public:
// Enables copying the object instead of formatting it in the caller thread.
// This object is safe to copy. But we are in SAFE_LOGGING and it would
// be formatted on the caller thread without this tag.
using copy_loggable_t = std::true_type;
foo(int m) : mo(m) {};
friend ostream& operator<<(ostream& os, const foo& f)
{
os << f.mo;
return os;
}
int mo;
};
.
class foo
{
public:
// With SAFE_LOGGING this class will always be formatted by default
// on the caller thread and a string will be copied to the queue
foo(int m) : mo(m) {};
friend ostream& operator<<(ostream& os, const foo& f)
{
os << f.mo;
return os;
}
int mo;
};
Unsafe Logging (Current Mode)
This mode will always attempt to copy all objects and format them in a backend logger thread.
The user has to be extra careful about objects that contain a mutable reference or a pointer as those members can change at any time :
after LOG_() was called but before formatting happened
during formatting
The text was updated successfully, but these errors were encountered:
Currently Quill copies all user defined types and then formats them on a backend thread. This leads problems when user defined types include a mutable reference or pointer to another object.
I am thinking to have two modes available. It should be able to switch between them with a preprocessor definition.
Safe Logging
If this mode is used without providing a tag to all the safe objects it will degrade performance.
However, if used correctly it can achieve the same performance as unsafe logging in a safer way.
This mode will copy all safe to copy types that accepted by
printf
to the spsc queue and format them later on the backend logger thread.For any user defined types check if
copy_loggable_t
tag is defined and copy the object without formatting, otherwise if the tag is not defined fallback to callingoperator<<
on the caller thread.For all related
stl
objects and containers check the underlying type against 1) and 2) and decide whether to copy or format the container on the caller thread.example :
.
Unsafe Logging (Current Mode)
This mode will always attempt to copy all objects and format them in a backend logger thread.
The user has to be extra careful about objects that contain a mutable reference or a pointer as those members can change at any time :
LOG_()
was called but before formatting happenedThe text was updated successfully, but these errors were encountered: