mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Make debug trace be per
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11615 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3e31f7a2e7
commit
9128ceae51
1 changed files with 22 additions and 10 deletions
|
@ -41,7 +41,6 @@
|
|||
#include <sys/file.h>
|
||||
|
||||
static NSString *httpVersion = @"1.1";
|
||||
static BOOL debug = NO;
|
||||
|
||||
char emp[64] = {
|
||||
'A','B','C','D','E','F','G','H','I','J','K','L','M',
|
||||
|
@ -54,6 +53,7 @@ char emp[64] = {
|
|||
@interface GSHTTPURLHandle : NSURLHandle
|
||||
{
|
||||
BOOL tunnel;
|
||||
BOOL debug;
|
||||
NSFileHandle *sock;
|
||||
NSURL *url;
|
||||
NSMutableData *dat;
|
||||
|
@ -72,6 +72,7 @@ char emp[64] = {
|
|||
} connectionState;
|
||||
}
|
||||
- (NSString*) encodebase64: (NSString*) input;
|
||||
- (void) setDebug: (BOOL)flag;
|
||||
@end
|
||||
|
||||
|
||||
|
@ -80,11 +81,16 @@ char emp[64] = {
|
|||
static NSMutableDictionary *urlCache = nil;
|
||||
static NSLock *urlLock = nil;
|
||||
|
||||
static NSLock *debugLock = nil;
|
||||
static char debugFile[128];
|
||||
|
||||
static void debugRead(NSData *data)
|
||||
{
|
||||
NSString *s = [NSString stringWithFormat: @"/tmp/GSHTTP.%d", getpid()];
|
||||
int d = open([s cString], O_WRONLY|O_CREAT|O_APPEND, 0644);
|
||||
NSString *s;
|
||||
int d;
|
||||
|
||||
[debugLock lock];
|
||||
d = open(debugFile, O_WRONLY|O_CREAT|O_APPEND, 0644);
|
||||
if (d >= 0)
|
||||
{
|
||||
s = [NSString stringWithFormat: @"\nRead %@ -\n", [NSDate date]];
|
||||
|
@ -92,12 +98,15 @@ static void debugRead(NSData *data)
|
|||
write(d, [data bytes], [data length]);
|
||||
close(d);
|
||||
}
|
||||
[debugLock unlock];
|
||||
}
|
||||
static void debugWrite(NSData *data)
|
||||
{
|
||||
NSString *s = [NSString stringWithFormat: @"/tmp/GSHTTP.%d", getpid()];
|
||||
int d = open([s cString], O_WRONLY|O_CREAT|O_APPEND, 0644);
|
||||
NSString *s;
|
||||
int d;
|
||||
|
||||
[debugLock lock];
|
||||
d = open(debugFile, O_WRONLY|O_CREAT|O_APPEND, 0644);
|
||||
if (d >= 0)
|
||||
{
|
||||
s = [NSString stringWithFormat: @"\nWrite %@ -\n", [NSDate date]];
|
||||
|
@ -105,6 +114,7 @@ static void debugWrite(NSData *data)
|
|||
write(d, [data bytes], [data length]);
|
||||
close(d);
|
||||
}
|
||||
[debugLock unlock];
|
||||
}
|
||||
|
||||
+ (NSURLHandle*) cachedHandleForURL: (NSURL*)newUrl
|
||||
|
@ -131,14 +141,11 @@ static void debugWrite(NSData *data)
|
|||
{
|
||||
urlCache = [NSMutableDictionary new];
|
||||
urlLock = [NSLock new];
|
||||
debugLock = [NSLock new];
|
||||
sprintf(debugFile, "/tmp/GSHTTP.%d", getpid());
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) setDebug: (BOOL)flag
|
||||
{
|
||||
debug = flag;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(sock);
|
||||
|
@ -688,6 +695,11 @@ static void debugWrite(NSData *data)
|
|||
return result;
|
||||
}
|
||||
|
||||
- (void) setDebug: (BOOL)flag
|
||||
{
|
||||
debug = flag;
|
||||
}
|
||||
|
||||
- (BOOL) writeData: (NSData*)d
|
||||
{
|
||||
ASSIGN(wData, d);
|
||||
|
|
Loading…
Reference in a new issue