Fixed the log file output when DEBUG=2. PRINT() is called from global
initializers before sLogFile was created in the InputServer constructor. Even moving the log file creation to a global initializer didn't help, since the order is not guaranteed. So I changed the code to create the log file on the fly in the PRINT method. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24014 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -60,10 +60,6 @@ DeviceManager InputServer::gDeviceManager;
|
|||||||
|
|
||||||
KeymapMethod InputServer::gKeymapMethod;
|
KeymapMethod InputServer::gKeymapMethod;
|
||||||
|
|
||||||
#if DEBUG == 2
|
|
||||||
FILE *InputServer::sLogFile = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" _EXPORT BView* instantiate_deskbar_item();
|
extern "C" _EXPORT BView* instantiate_deskbar_item();
|
||||||
|
|
||||||
@@ -147,11 +143,6 @@ InputServer::InputServer()
|
|||||||
fAppServerPort(-1),
|
fAppServerPort(-1),
|
||||||
fCursorArea(-1)
|
fCursorArea(-1)
|
||||||
{
|
{
|
||||||
#if DEBUG == 2
|
|
||||||
if (sLogFile == NULL)
|
|
||||||
sLogFile = fopen("/var/log/input_server.log", "a");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CALLED();
|
CALLED();
|
||||||
gInputServer = this;
|
gInputServer = this;
|
||||||
|
|
||||||
@@ -225,10 +216,6 @@ InputServer::~InputServer()
|
|||||||
fAddOnManager->Quit();
|
fAddOnManager->Quit();
|
||||||
|
|
||||||
_ReleaseInput(NULL);
|
_ReleaseInput(NULL);
|
||||||
|
|
||||||
#if DEBUG == 2
|
|
||||||
fclose(sLogFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ class BottomlineWindow;
|
|||||||
|
|
||||||
class InputDeviceListItem {
|
class InputDeviceListItem {
|
||||||
public:
|
public:
|
||||||
InputDeviceListItem(BInputServerDevice& serverDevice, input_device_ref& device);
|
InputDeviceListItem(BInputServerDevice& serverDevice,
|
||||||
|
input_device_ref& device);
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
@@ -75,7 +76,8 @@ class _BDeviceAddOn_ {
|
|||||||
|
|
||||||
class _BMethodAddOn_ {
|
class _BMethodAddOn_ {
|
||||||
public:
|
public:
|
||||||
_BMethodAddOn_(BInputServerMethod *method, const char* name, const uchar* icon);
|
_BMethodAddOn_(BInputServerMethod *method, const char* name,
|
||||||
|
const uchar* icon);
|
||||||
~_BMethodAddOn_();
|
~_BMethodAddOn_();
|
||||||
|
|
||||||
status_t SetName(const char* name);
|
status_t SetName(const char* name);
|
||||||
@@ -236,10 +238,6 @@ class InputServer : public BApplication {
|
|||||||
uint32* fCursorBuffer;
|
uint32* fCursorBuffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEBUG == 2
|
|
||||||
public:
|
|
||||||
static FILE *sLogFile;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern InputServer* gInputServer;
|
extern InputServer* gInputServer;
|
||||||
@@ -247,8 +245,17 @@ extern InputServer* gInputServer;
|
|||||||
#if DEBUG >= 1
|
#if DEBUG >= 1
|
||||||
# if DEBUG == 2
|
# if DEBUG == 2
|
||||||
# undef PRINT
|
# undef PRINT
|
||||||
inline void _iprint(const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); vsprintf(buf, fmt, ap); va_end(ap); \
|
inline void _iprint(const char *fmt, ...) {
|
||||||
fputs(buf, InputServer::sLogFile); fflush(InputServer::sLogFile); }
|
FILE* log = fopen("/var/log/input_server.log", "a");
|
||||||
|
char buf[1024];
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsprintf(buf, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
fputs(buf, log);
|
||||||
|
fflush(log);
|
||||||
|
fclose(log);
|
||||||
|
}
|
||||||
# define PRINT(x) _iprint x
|
# define PRINT(x) _iprint x
|
||||||
# else
|
# else
|
||||||
# undef PRINT
|
# undef PRINT
|
||||||
|
|||||||
Reference in New Issue
Block a user