mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-22 19:31:53 +00:00
improve shutdown logging and archiving of debug logs to correct date
This commit is contained in:
parent
4820767b98
commit
c828a0edfc
1 changed files with 45 additions and 24 deletions
69
EcProcess.m
69
EcProcess.m
|
@ -1496,7 +1496,7 @@ static NSString *noFiles = @"No log files to archive";
|
||||||
return [dateClass dateWithTimeIntervalSinceReferenceDate: lastOP];
|
return [dateClass dateWithTimeIntervalSinceReferenceDate: lastOP];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) cmdLogEnd: (NSString*)name
|
- (NSString*) ecLogEnd: (NSString*)name to: (NSDate*)when
|
||||||
{
|
{
|
||||||
NSString *status = nil;
|
NSString *status = nil;
|
||||||
|
|
||||||
|
@ -1516,7 +1516,7 @@ static NSString *noFiles = @"No log files to archive";
|
||||||
{
|
{
|
||||||
/* If the file is empty, remove it, otherwise archive it.
|
/* If the file is empty, remove it, otherwise archive it.
|
||||||
*/
|
*/
|
||||||
status = [self _moveLog: name to: nil];
|
status = [self _moveLog: name to: when];
|
||||||
|
|
||||||
/* Ensure that all data is written to file, then close it unless it's
|
/* Ensure that all data is written to file, then close it unless it's
|
||||||
* stderr (which we must keep open for logging at all times).
|
* stderr (which we must keep open for logging at all times).
|
||||||
|
@ -1540,6 +1540,11 @@ static NSString *noFiles = @"No log files to archive";
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString*) cmdLogEnd: (NSString*)name
|
||||||
|
{
|
||||||
|
return [self ecLogEnd: name to: nil];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSFileHandle*) cmdLogFile: (NSString*)name
|
- (NSFileHandle*) cmdLogFile: (NSString*)name
|
||||||
{
|
{
|
||||||
NSFileHandle *hdl;
|
NSFileHandle *hdl;
|
||||||
|
@ -3750,6 +3755,8 @@ With two parameters ('maximum' and a number),\n\
|
||||||
|
|
||||||
- (oneway void) cmdQuit: (NSInteger)status
|
- (oneway void) cmdQuit: (NSInteger)status
|
||||||
{
|
{
|
||||||
|
NSDate *now = [NSDate date];
|
||||||
|
|
||||||
if (reservedPipe[1] > 0)
|
if (reservedPipe[1] > 0)
|
||||||
{
|
{
|
||||||
close(reservedPipe[0]); reservedPipe[0] = 0;
|
close(reservedPipe[0]); reservedPipe[0] = 0;
|
||||||
|
@ -3771,29 +3778,10 @@ With two parameters ('maximum' and a number),\n\
|
||||||
}
|
}
|
||||||
[alarmDestination shutdown];
|
[alarmDestination shutdown];
|
||||||
|
|
||||||
[self cmdFlushLogs];
|
/* Almost done ... flush any logs then write the final audit log and
|
||||||
|
* flush again (so that audit log should be the last in the file).
|
||||||
[self cmdUnregister];
|
|
||||||
|
|
||||||
[alarmDestination shutdown];
|
|
||||||
DESTROY(alarmDestination);
|
|
||||||
|
|
||||||
[EcProcConnection invalidate];
|
|
||||||
|
|
||||||
{
|
|
||||||
NSArray *keys;
|
|
||||||
unsigned index;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Close down all log files.
|
|
||||||
*/
|
*/
|
||||||
keys = [cmdLogMap allKeys];
|
[self cmdFlushLogs];
|
||||||
for (index = 0; index < [keys count]; index++)
|
|
||||||
{
|
|
||||||
[self cmdLogEnd: [keys objectAtIndex: index]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 == status)
|
if (0 == status)
|
||||||
{
|
{
|
||||||
[self cmdAudit: @"Shutdown '%@'", [self cmdName]];
|
[self cmdAudit: @"Shutdown '%@'", [self cmdName]];
|
||||||
|
@ -3805,6 +3793,39 @@ With two parameters ('maximum' and a number),\n\
|
||||||
}
|
}
|
||||||
[auditLogger flush];
|
[auditLogger flush];
|
||||||
|
|
||||||
|
/* Now that the audit log has been flushed to the Command/Control
|
||||||
|
* servers, we can unregister from Command.
|
||||||
|
*/
|
||||||
|
[self cmdUnregister];
|
||||||
|
|
||||||
|
/* Re-do the alarm destination shut down, just in case an alarm
|
||||||
|
* occurred while we were flushing logs and/or unregistering.
|
||||||
|
*/
|
||||||
|
[alarmDestination shutdown];
|
||||||
|
DESTROY(alarmDestination);
|
||||||
|
|
||||||
|
/* Ensure our DO connection is invalidated so there will be no more
|
||||||
|
* remote communications.
|
||||||
|
*/
|
||||||
|
[EcProcConnection invalidate];
|
||||||
|
|
||||||
|
/* The very last thing we do is to close down the log filed so they
|
||||||
|
* are archived to the correct directory for the current date.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
NSArray *keys;
|
||||||
|
unsigned index;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close down all log files.
|
||||||
|
*/
|
||||||
|
keys = [cmdLogMap allKeys];
|
||||||
|
for (index = 0; index < [keys count]; index++)
|
||||||
|
{
|
||||||
|
[self ecLogEnd: [keys objectAtIndex: index] to: now];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue