mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-20 18:32:09 +00:00
Use well known host name more consistenctly
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/devmodules/dev-libs/ec@35147 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6a196d1400
commit
c0ca42ec76
3 changed files with 33 additions and 14 deletions
|
@ -35,6 +35,7 @@
|
||||||
#import <Foundation/NSObject.h>
|
#import <Foundation/NSObject.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
|
|
||||||
|
#import "EcHost.h"
|
||||||
#import "EcProcess.h"
|
#import "EcProcess.h"
|
||||||
#import "EcAlarm.h"
|
#import "EcAlarm.h"
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ EcMakeManagedObject(NSString *host, NSString *process, NSString *component)
|
||||||
|
|
||||||
if (nil == host)
|
if (nil == host)
|
||||||
{
|
{
|
||||||
host = [[NSHost currentHost] name];
|
host = [[NSHost currentHost] wellKnownName];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <GNUstepBase/GSMime.h>
|
#import <GNUstepBase/GSMime.h>
|
||||||
|
|
||||||
|
#import "EcHost.h"
|
||||||
#import "EcProcess.h"
|
#import "EcProcess.h"
|
||||||
#import "EcAlerter.h"
|
#import "EcAlerter.h"
|
||||||
#import "NSFileHandle+Printf.h"
|
#import "NSFileHandle+Printf.h"
|
||||||
|
@ -393,7 +394,7 @@ replaceFields(NSDictionary *fields)
|
||||||
if (nil == eFrom)
|
if (nil == eFrom)
|
||||||
{
|
{
|
||||||
eFrom = [NSString stringWithFormat: @"alerter@%@",
|
eFrom = [NSString stringWithFormat: @"alerter@%@",
|
||||||
[[NSHost currentHost] name]];
|
[[NSHost currentHost] wellKnownName]];
|
||||||
RETAIN(eFrom);
|
RETAIN(eFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
41
EcProcess.m
41
EcProcess.m
|
@ -354,18 +354,24 @@ cmdLogKey(EcLogType t)
|
||||||
NSString*
|
NSString*
|
||||||
cmdLogName()
|
cmdLogName()
|
||||||
{
|
{
|
||||||
static NSString *n = nil;
|
static NSString *cmdLogName = nil;
|
||||||
|
|
||||||
if (n == nil)
|
if (nil == cmdLogName)
|
||||||
{
|
{
|
||||||
n = [EcProc cmdName];
|
[ecLock lock];
|
||||||
if (n == nil)
|
if (nil == cmdLogName)
|
||||||
{
|
{
|
||||||
n = [[NSProcessInfo processInfo] processName];
|
NSString *n = [EcProc cmdName];
|
||||||
|
|
||||||
|
if (nil == n)
|
||||||
|
{
|
||||||
|
n = [[NSProcessInfo processInfo] processName];
|
||||||
|
}
|
||||||
|
cmdLogName = [n copy];
|
||||||
}
|
}
|
||||||
n = [n copy];
|
[ecLock unlock];
|
||||||
}
|
}
|
||||||
return n;
|
return cmdLogName;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString*
|
NSString*
|
||||||
|
@ -381,7 +387,7 @@ cmdLogFormat(EcLogType t, NSString *fmt)
|
||||||
|
|
||||||
if (h == nil)
|
if (h == nil)
|
||||||
{
|
{
|
||||||
h = [[[NSHost currentHost] name] copy];
|
h = [[[NSHost currentHost] wellKnownName] copy];
|
||||||
}
|
}
|
||||||
if (l == nil)
|
if (l == nil)
|
||||||
{
|
{
|
||||||
|
@ -433,6 +439,16 @@ static NSMutableArray *updateHandlers = nil;
|
||||||
static NSMutableDictionary *servers = nil;
|
static NSMutableDictionary *servers = nil;
|
||||||
|
|
||||||
static NSString *hostName = nil;
|
static NSString *hostName = nil;
|
||||||
|
static NSString *
|
||||||
|
ecHostName()
|
||||||
|
{
|
||||||
|
NSString *name;
|
||||||
|
|
||||||
|
[ecLock lock];
|
||||||
|
name = [hostName retain];
|
||||||
|
[ecLock unlock];
|
||||||
|
return [name autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
#define DEFMEMALLOWED 50
|
#define DEFMEMALLOWED 50
|
||||||
static int memAllowed = DEFMEMALLOWED;
|
static int memAllowed = DEFMEMALLOWED;
|
||||||
|
@ -1064,6 +1080,7 @@ static NSString *noFiles = @"No log files to archive";
|
||||||
if (nil != dict)
|
if (nil != dict)
|
||||||
{
|
{
|
||||||
[NSHost setWellKnownNames: dict];
|
[NSHost setWellKnownNames: dict];
|
||||||
|
ASSIGN(hostName, [[NSHost currentHost] wellKnownName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
GSDebugAllocationActive([cmdDefs boolForKey: @"Memory"]);
|
GSDebugAllocationActive([cmdDefs boolForKey: @"Memory"]);
|
||||||
|
@ -1332,7 +1349,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
||||||
stringClass = [NSString class];
|
stringClass = [NSString class];
|
||||||
cmdLogMap = [[NSMutableDictionary alloc] initWithCapacity: 4];
|
cmdLogMap = [[NSMutableDictionary alloc] initWithCapacity: 4];
|
||||||
|
|
||||||
hostName = RETAIN([[NSHost currentHost] name]);
|
hostName = [[[NSHost currentHost] wellKnownName] retain];
|
||||||
|
|
||||||
cmdDebugModes = [[NSMutableSet alloc] initWithCapacity: 4];
|
cmdDebugModes = [[NSMutableSet alloc] initWithCapacity: 4];
|
||||||
cmdDebugKnown = [[NSMutableDictionary alloc] initWithCapacity: 4];
|
cmdDebugKnown = [[NSMutableDictionary alloc] initWithCapacity: 4];
|
||||||
|
@ -2534,7 +2551,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self cmdPrintf: @"\n%@ on %@ running since %@\n\n",
|
[self cmdPrintf: @"\n%@ on %@ running since %@\n\n",
|
||||||
cmdLogName(), hostName, [self cmdStarted]];
|
cmdLogName(), ecHostName(), [self cmdStarted]];
|
||||||
|
|
||||||
if (NO == [cmdDefs boolForKey: @"Memory"])
|
if (NO == [cmdDefs boolForKey: @"Memory"])
|
||||||
{
|
{
|
||||||
|
@ -2560,7 +2577,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self cmdPrintf: @"\n%@ on %@ running since %@\n",
|
[self cmdPrintf: @"\n%@ on %@ running since %@\n",
|
||||||
cmdLogName(), hostName, [self cmdStarted]];
|
cmdLogName(), ecHostName(), [self cmdStarted]];
|
||||||
if ([self cmdLastIP] != nil)
|
if ([self cmdLastIP] != nil)
|
||||||
{
|
{
|
||||||
[self cmdPrintf: @"Last IP at %@\n", [self cmdLastIP]];
|
[self cmdPrintf: @"Last IP at %@\n", [self cmdLastIP]];
|
||||||
|
@ -2795,7 +2812,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
||||||
- (NSString*) description
|
- (NSString*) description
|
||||||
{
|
{
|
||||||
return [stringClass stringWithFormat: @"%@ (%@) on %@",
|
return [stringClass stringWithFormat: @"%@ (%@) on %@",
|
||||||
[super description], cmdLogName(), hostName];
|
[super description], cmdLogName(), ecHostName()];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
|
|
Loading…
Reference in a new issue