I'm trying to write a log library which would use an external tool
To make the library more natural to use, i would like to be able to detect the namespace in which cout is used.
concretly the result should be used like this
namespace A
{
void foo()
{
cout << "Something went very wrong" << endl;
}
}
namespace B
{
void bar()
{
cout << "C should equal 3" << endl;
}
}
int main()
{
B::bar();
A::foo();
}
and the resulting output should look like this
MODULE::B : C should equal 3
MODULE::A : Something went very wrong
I already use std::streambuf
to add certain keywords to the output of cout, all i need to be able to do is specify which streambuf to use in which namespace.
How do i achieve this?
Also the library i'm making is to be integrated in a project with multiple namespaces which making heavy uses of the using namespace
declaration. I would need a solution which will not require to remove these declarations.
edit1: i don't care having to specify by hand which namespace is associated with which string or adding objects to any of the used namespaces (except std
of course)