Skip to content
Permalink
Browse files

Enable logging with BeDC

  • Loading branch information...
RAJAGOPALAN-GANGADHARAN authored and pulkomandy committed Jun 7, 2019
1 parent df53e44 commit 3b33d1ac69d2f89ea7f660b3fce881148e6ad1a2
@@ -27,6 +27,8 @@
#include "NotImplemented.h"

#include "Logging.h"
#include "BeDC.h"
#include <string>

namespace WebCore {

@@ -39,4 +41,18 @@ WTFLogChannel* notImplementedLoggingChannel()

#endif

#if LOG_DISABLED

int LogColor(char* string)
{
std::string temp(string);
if(temp == "application/x-vnd.lh-MiniBrowser")
return DC_GREEN;
else if(temp == "application/x-vnd.haiku-webkit.webprocess")
return DC_RED;
else
return DC_BLUE;
}

#endif
}
@@ -28,14 +28,35 @@

#include <wtf/Assertions.h>

#if PLATFORM(HAIKU)
#include "BeDC.h"
#include <Application.h>
#include <Roster.h>
#endif

#if PLATFORM(GTK)
#define suppressNotImplementedWarning() getenv("DISABLE_NI_WARNING")
#else
#define suppressNotImplementedWarning() false
#endif

#if LOG_DISABLED
#define notImplemented() ((void)0)

#if PLATFORM(HAIKU)
namespace WebCore {
WEBCORE_EXPORT int LogColor(char* string);
}
#define notImplemented() do { \
static bool havePrinted = false; \
if (!havePrinted) { \
app_info* appInfo = new app_info(); \
be_app->GetAppInfo(appInfo); \
BeDC dc(appInfo->signature,WebCore::LogColor(appInfo->signature)); \
dc.SendFormat("UNIMPLEMENTED: %s %d %s",__FILE__,__LINE__,__PRETTY_FUNCTION__); \
havePrinted = true; \
} \
} while (0)
#endif

#else

namespace WebCore {
@@ -0,0 +1,195 @@
//////////////////////////////////////////////////////////////////////////
// BeDC.h //
// The header file to use with BeDC //
// //
// Written By: Magnus Landahl //
// E-Mail: magnus.landahl@swipnet.se //
// //
// Copyright © Magnus Landahl - Stockholm 2000 //
//////////////////////////////////////////////////////////////////////////

#ifndef _BE_DC_H_
#define _BE_DC_H_

//Messages types
#define DC_MESSAGE 0
#define DC_SUCCESS DC_MESSAGE + 1
#define DC_ERROR DC_MESSAGE + 2
#define DC_SEPARATOR DC_MESSAGE + 3
#define DC_CLEAR DC_MESSAGE + 4
//---------------

//Color defines
#define DEF_COLOR 0
#define DC_WHITE DEF_COLOR + 1
#define DC_BLACK DEF_COLOR + 2
#define DC_BLUE DEF_COLOR + 3
#define DC_RED DEF_COLOR + 4
#define DC_YELLOW DEF_COLOR + 5
#define DC_GREEN DEF_COLOR + 6
//---------------

#define BEDC_MESSAGE 'bedc'

#define BEDC_MAIN_TYPE 0
#define BEDC_BMESSAGE BEDC_MAIN_TYPE + 1
#define BEDC_PLAIN_MESSAGE BEDC_MAIN_TYPE + 2
#define BEDC_VER "1.0"

#include <TypeConstants.h>
#include <SupportDefs.h>
#include <Messenger.h>
#include <Message.h>
#include <String.h>
#include <string.h>
#include <stdio.h>
#include <Point.h>
#include <Rect.h>

class BeDC
{
////////////////////////////////////////////////
// Public Procedures

public:
BeDC(const char *c_name = "Application", int8 color = DEF_COLOR){
name = strdup(c_name);
s_color = color;
}

~BeDC(){
delete name;
}

//Send a message
void SendMessage(const char *text, int8 type = DC_MESSAGE){
BMessage message(BEDC_MESSAGE);
message.AddString( "bedc_name", name);
message.AddInt8( "bedc_type", type);
message.AddString( "bedc_text", text);
message.AddInt8( "bedc_color", s_color);
message.AddString( "bedc_ver", BEDC_VER);
message.AddInt8( "bedc_main_type", BEDC_PLAIN_MESSAGE);
SendMessageToApp(&message);
}
//---------------

//Send a format string - parameters
void SendFormat(const char *text, ...) __attribute__((format(printf, 2, 3))) {
char buffer[1024];
va_list args;

va_start(args, text);
vsprintf(buffer, text, args);
va_end(args);
SendMessage(buffer, DC_MESSAGE);
}

void SendFormatT(const char *text, int8 type, ...) __attribute__((format(printf, 2, 4))) {
char buffer[1024];
va_list args;

va_start(args, type);
vsprintf(buffer, text, args);
va_end(args);
SendMessage(buffer, type);
}
//---------------

//Dump a BMessage
void DumpBMessage(BMessage *Message, const char *desc = "", int8 type = DC_MESSAGE){
Message->AddInt32( "bedc_what", Message->what);
Message->AddInt8( "bedc_main_type", BEDC_BMESSAGE);

Message->AddInt8( "bedc_type", type);
Message->AddString( "bedc_name", name);
Message->AddString( "bedc_desc", desc);
Message->AddInt8( "bedc_color",s_color);
Message->AddString( "bedc_ver", BEDC_VER);

Message->what = BEDC_MESSAGE;
SendMessageToApp(Message);
}
//---------------

//Send a separator (Add a separator)
void AddSeparator(){
SendMessage("Separator", DC_SEPARATOR);
}
//---------------

//Send a clear message (Clear the window that is online)
void Clear(){
SendMessage("Clear", DC_CLEAR);
}
//---------------

//Send an Int32
void SendInt( int32 integer, const char *desc = NULL, int8 type = DC_MESSAGE){
str.SetTo("");
if (desc != NULL) str << desc; else
str << "Integer: ";
str << integer;
SendMessage((char *)str.String(),type);
}
//---------------

//Send an Int64
void SendInt( int64 integer, const char *desc = NULL, int8 type = DC_MESSAGE){
str.SetTo("");
if (desc != NULL) str << desc; else
str << "Integer: ";
str << integer;
SendMessage((char *)str.String(),type);
}
//---------------

//Send a BPoint
void SendPoint( BPoint point, const char *desc = NULL, int8 type = DC_MESSAGE){
str.SetTo("");
if (desc != NULL) str << desc; else
str << "Point: ";
str << "X = " << point.x << " Y = " << point.y;
SendMessage((char *)str.String(),type);
}
//---------------

//Send a BRect
void SendRect( BRect rect, const char *desc = NULL, int8 type = DC_MESSAGE){
str.SetTo("");
if (desc != NULL) str << desc; else
str << "Rectangle: ";
str << "Left = " << rect.left << " Top = " << rect.top
<< " Right = " << rect.right << " Bottom = " << rect.bottom;
SendMessage((char *)str.String(),type);
}
//---------------

////////////////////////////////////////////
// Private Data
private:
char *name;
int8 s_color;
BString str;

void SendMessageToApp(BMessage *Msg){
BMessenger messenger("application/x-vnd.ml-BeDCApp");
if (messenger.IsValid()) messenger.SendMessage(Msg);
}
};

#endif














@@ -463,7 +463,7 @@ class Connection : public ThreadSafeRefCounted<Connection, WTF::DestructionThrea

template<typename T>
bool Connection::send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions)
{fprintf(stderr,"(%s-%ld)",__PRETTY_FUNCTION__,m_connectedProcess.connectedProcess);
{
COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);

auto encoder = std::make_unique<Encoder>(T::receiverName(), T::name(), destinationID);
@@ -549,19 +549,17 @@ template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&&

// Encode the rest of the input arguments.
encoder->encode(message.arguments());
fprintf(stderr,"\n%s place 1\n",__PRETTY_FUNCTION__);
// Now send the message and wait for a reply.
std::unique_ptr<Decoder> replyDecoder = sendSyncMessage(syncRequestID, WTFMove(encoder), timeout, sendSyncOptions);
if (!replyDecoder)
return false;
fprintf(stderr,"\n%s place 2\n",__PRETTY_FUNCTION__);
// Decode the reply.
Optional<typename T::ReplyArguments> replyArguments;
*replyDecoder >> replyArguments;
if (!replyArguments)
return false;fprintf(stderr,"\n%s place 3\n",__PRETTY_FUNCTION__);
return false;
moveTuple(WTFMove(*replyArguments), reply);
return true;fprintf(stderr,"\n%s place 4\n",__PRETTY_FUNCTION__);
return true;
}

template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions)

0 comments on commit 3b33d1a

Please sign in to comment.
You can’t perform that action at this time.