Skip to content

Instantly share code, notes, and snippets.

@hanya
Created May 20, 2017 15:48
Show Gist options
  • Save hanya/03d248e7d116d5c0b2f7063a5259b382 to your computer and use it in GitHub Desktop.
Save hanya/03d248e7d116d5c0b2f7063a5259b382 to your computer and use it in GitHub Desktop.
logger application to take some message and write into standard output on Haiku OS
// Compile as follows:
// g++ logger.cc -lbe -o logger
#include <Application.h>
#include <iostream>
#include <string.h>
#define LOGGER "application/x-vnd.Logger"
enum {
LOG = 'Logg',
};
#define LOG_ENTRY "log"
class App : public BApplication
{
public:
App(void);
virtual void MessageReceived(BMessage *msg);
};
App::App(void)
: BApplication(LOGGER)
{
}
void App::MessageReceived(BMessage *msg)
{
switch (msg->what)
{
case LOG:
{
const char *log = msg->GetString(LOG_ENTRY);
if (log != NULL) {
std::cout << log << std::endl;
}
break;
}
default:
{
App::MessageReceived(msg);
break;
}
}
}
int main(void)
{
App *app = new App();
app->Run();
delete app;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment