Created
May 20, 2017 15:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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