2 * Copyright 2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Ma Jie, china.majie at gmail
9 #include "PoorManLogger.h"
12 #include <netinet/in.h>
14 #include <Messenger.h>
16 #include <TypeConstants.h>
18 #include "PoorManApplication.h"
19 #include "PoorManWindow.h"
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())
32 BMessenger
messenger(window
);
33 BMessage
message(MSG_LOG
);
35 if(message
.AddString("cstring", msg
) != B_OK
)
38 if(message
.AddData("time_t", B_TIME_TYPE
, &now
, sizeof(time_t)) != B_OK
)
41 if(addr
!= INADDR_NONE
)
42 message
.AddData("in_addr_t", B_ANY_TYPE
, &addr
, sizeof(in_addr_t
));
45 message
.AddData("rgb_color", B_RGB_COLOR_TYPE
, &color
, sizeof(rgb_color
));
47 messenger
.SendMessage(&message
, (BHandler
*)NULL
, 1000000);