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:
Stephan Aßmus 2008-02-19 11:32:41 +00:00
parent 9518dd74a7
commit ddb44fda2c
2 changed files with 15 additions and 21 deletions

View File

@ -60,10 +60,6 @@ DeviceManager InputServer::gDeviceManager;
KeymapMethod InputServer::gKeymapMethod;
#if DEBUG == 2
FILE *InputServer::sLogFile = NULL;
#endif
extern "C" _EXPORT BView* instantiate_deskbar_item();
@ -147,11 +143,6 @@ InputServer::InputServer()
fAppServerPort(-1),
fCursorArea(-1)
{
#if DEBUG == 2
if (sLogFile == NULL)
sLogFile = fopen("/var/log/input_server.log", "a");
#endif
CALLED();
gInputServer = this;
@ -225,10 +216,6 @@ InputServer::~InputServer()
fAddOnManager->Quit();
_ReleaseInput(NULL);
#if DEBUG == 2
fclose(sLogFile);
#endif
}

View File

@ -42,7 +42,8 @@ class BottomlineWindow;
class InputDeviceListItem {
public:
InputDeviceListItem(BInputServerDevice& serverDevice, input_device_ref& device);
InputDeviceListItem(BInputServerDevice& serverDevice,
input_device_ref& device);
void Start();
void Stop();
@ -75,7 +76,8 @@ class _BDeviceAddOn_ {
class _BMethodAddOn_ {
public:
_BMethodAddOn_(BInputServerMethod *method, const char* name, const uchar* icon);
_BMethodAddOn_(BInputServerMethod *method, const char* name,
const uchar* icon);
~_BMethodAddOn_();
status_t SetName(const char* name);
@ -236,10 +238,6 @@ class InputServer : public BApplication {
uint32* fCursorBuffer;
#endif
#if DEBUG == 2
public:
static FILE *sLogFile;
#endif
};
extern InputServer* gInputServer;
@ -247,8 +245,17 @@ extern InputServer* gInputServer;
#if DEBUG >= 1
# if DEBUG == 2
# 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); \
fputs(buf, InputServer::sLogFile); fflush(InputServer::sLogFile); }
inline void _iprint(const char *fmt, ...) {
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
# else
# undef PRINT