btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / poorman / PoorManLogger.cpp
blob9d47475bacd9b086b8db52cda02bdc6a398ea2bf
1 /*
2 * Copyright 2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Author(s):
6 * Ma Jie, china.majie at gmail
7 */
9 #include "PoorManLogger.h"
11 #include <time.h>
12 #include <netinet/in.h>
14 #include <Messenger.h>
15 #include <Message.h>
16 #include <TypeConstants.h>
18 #include "PoorManApplication.h"
19 #include "PoorManWindow.h"
21 void
22 poorman_log(const char* msg, bool needTimeHeader,
23 in_addr_t addr, rgb_color color)
25 time_t now = time(NULL);
27 PoorManWindow* window = static_cast<PoorManApplication*>(be_app)->GetPoorManWindow();
29 if(!window->LogConsoleFlag() && !window->LogFileFlag())
30 return;
32 BMessenger messenger(window);
33 BMessage message(MSG_LOG);
35 if(message.AddString("cstring", msg) != B_OK)
36 return;
37 if(needTimeHeader){
38 if(message.AddData("time_t", B_TIME_TYPE, &now, sizeof(time_t)) != B_OK)
39 return;
41 if(addr != INADDR_NONE)
42 message.AddData("in_addr_t", B_ANY_TYPE, &addr, sizeof(in_addr_t));
44 if(color != BLACK)
45 message.AddData("rgb_color", B_RGB_COLOR_TYPE, &color, sizeof(rgb_color));
47 messenger.SendMessage(&message, (BHandler*)NULL, 1000000);