fixup! Added pong
This commit is contained in:
@@ -174,6 +174,8 @@ main()
|
|||||||
{
|
{
|
||||||
redirect_to_log(std::cout);
|
redirect_to_log(std::cout);
|
||||||
redirect_to_log(std::cerr);
|
redirect_to_log(std::cerr);
|
||||||
|
redirect_to_log(L4::cout);
|
||||||
|
redirect_to_log(L4::cerr);
|
||||||
Main().run();
|
Main().run();
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,10 +2,16 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <l4/cxx/iostream>
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
void send_ipc(std::string const &msg);
|
static inline void
|
||||||
void redirect_to_log(std::ostream &os);
|
send_ipc(std::string const &msg);
|
||||||
|
static inline void
|
||||||
|
redirect_to_log(std::ostream &os);
|
||||||
|
static inline void
|
||||||
|
redirect_to_log(L4::BasicOStream &os);
|
||||||
|
|
||||||
void
|
void
|
||||||
send_ipc(std::string const &msg)
|
send_ipc(std::string const &msg)
|
||||||
@@ -29,16 +35,14 @@ public:
|
|||||||
Base::setp(&buffer.front(), &buffer.back());
|
Base::setp(&buffer.front(), &buffer.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
int_type
|
int_type overflow(int_type ch) override
|
||||||
overflow(int_type ch) override
|
|
||||||
{
|
{
|
||||||
Log_Buffer::sync();
|
Log_Buffer::sync();
|
||||||
Base::sputc(ch);
|
Base::sputc(ch);
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int sync() override
|
||||||
sync() override
|
|
||||||
{
|
{
|
||||||
send_ipc(buffer);
|
send_ipc(buffer);
|
||||||
Base::setp(this->pbase(), this->epptr());
|
Base::setp(this->pbase(), this->epptr());
|
||||||
@@ -46,6 +50,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Log_Backend : public L4::IOBackend
|
||||||
|
{
|
||||||
|
void write(char const *str, unsigned len) override { send_ipc({str, len}); };
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
redirect_to_log(std::ostream &os)
|
redirect_to_log(std::ostream &os)
|
||||||
{
|
{
|
||||||
@@ -55,3 +64,9 @@ redirect_to_log(std::ostream &os)
|
|||||||
// We should not free the old buffer because it has not been allocated
|
// We should not free the old buffer because it has not been allocated
|
||||||
// dynamically.
|
// dynamically.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
redirect_to_log(L4::BasicOStream &os)
|
||||||
|
{
|
||||||
|
os = {new Log_Backend{}};
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ main()
|
|||||||
{
|
{
|
||||||
redirect_to_log(std::cout);
|
redirect_to_log(std::cout);
|
||||||
redirect_to_log(std::cerr);
|
redirect_to_log(std::cerr);
|
||||||
|
redirect_to_log(L4::cout);
|
||||||
|
redirect_to_log(L4::cerr);
|
||||||
|
|
||||||
L4::cout << "PS Hello here am I\n";
|
L4::cout << "PS Hello here am I\n";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user