deprecate old error/alert methods

This commit is contained in:
Richard Frith-Macdonald 2020-01-27 15:27:57 +00:00
parent aecd4f8323
commit 85dfbfa006
7 changed files with 49 additions and 16 deletions

View file

@ -1,3 +1,13 @@
2020-01-27 Richard Frith-Macdonald <rfm@gnu.org>
* EcAlarmSinkSNMP.m:
* EcCommand.m:
* EcLogger.h:
* EcLogger.m:
* EcProcess.h:
* EcProcess.m:
Changes to formally deprecate cmdAlert:... and cmdError:...
2019-11-01 Richard Frith-Macdonald <rfm@gnu.org>
* EcCommand.m: Restructure so that all ways we can be informed that

View file

@ -35,6 +35,7 @@
#import "EcAlarmDestination.h"
#import "EcAlarmSinkSNMP.h"
#import "EcProcess.h"
#import "EcLogger.h"
static EcAlarmSinkSNMP *alarmSink = nil; // The singleton
static NSLock *classLock = nil;
@ -247,10 +248,12 @@ logSNMP(int major, int minor, void* server, void* client)
case LOG_EMERG:
case LOG_ALERT:
case LOG_CRIT:
[EcProc cmdAlert: @"%s", slm->msg]; break;
[[EcLogger loggerForType: LT_ALERT] log: @"%s", slm->msg];
break;
case LOG_ERR:
[EcProc cmdError: @"%s", slm->msg]; break;
[[EcLogger loggerForType: LT_ERROR] log: @"%s", slm->msg];
break;
case LOG_WARNING:
case LOG_NOTICE:

View file

@ -3443,7 +3443,8 @@ NSLog(@"Problem %@", localException);
objectForKey: NSFileSystemFreeSize] integerValue])
{
[mgr removeFileAtPath: src handler: nil];
[self cmdError: @"Unable to compress %@ (too big; deleted)", src];
EcExceptionMajor(nil,
@"Unable to compress %@ (too big; deleted)", src);
continue; // Not enough space free to compress
}
@ -3459,7 +3460,8 @@ NSLog(@"Problem %@", localException);
{
[dh closeFile];
[mgr removeFileAtPath: dst handler: nil];
[self cmdError: @"Unable to compress %@ to %@", src, dst];
EcExceptionMajor(nil,
@"Unable to compress %@ to %@", src, dst);
continue;
}

View file

@ -105,6 +105,10 @@
*/
- (void) log: (NSString*)fmt arguments: (va_list)args;
/* Calls -log:arguments:
*/
- (void) log: (NSString*)fmt, ... NS_FORMAT_FUNCTION(1,2);
/** Called when the user defaults system has changed and a configuration
* update may have occurred.
*/

View file

@ -515,6 +515,15 @@ static NSArray *modes;
}
}
- (void) log: (NSString*)fmt, ...
{
va_list ap;
va_start (ap, fmt);
[self log: fmt arguments: ap];
va_end (ap);
}
/* Should only be called on main thread.
*/
- (void) _timeout: (NSTimer*)t

View file

@ -754,7 +754,8 @@ extern NSString* cmdVersion(NSString *ver);
/** Deprecated; do not use.
*/
- (void) cmdAlert: (NSString*)fmt, ... NS_FORMAT_FUNCTION(1,2);
- (void) cmdAlert: (NSString*)fmt, ... NS_FORMAT_FUNCTION(1,2)
__attribute__((deprecated));
/** Archives debug log files into the appropriate subdirectory for the
* supplied date (or the files last modification date if when is nil).<br />
@ -823,7 +824,8 @@ extern NSString* cmdVersion(NSString *ver);
/** Deprecated; do not use.
*/
- (void) cmdError: (NSString*)fmt, ... NS_FORMAT_FUNCTION(1,2);
- (void) cmdError: (NSString*)fmt, ... NS_FORMAT_FUNCTION(1,2)
__attribute__((deprecated));
/** Flush logging information.
*/

View file

@ -2151,8 +2151,9 @@ static NSString *noFiles = @"No log files to archive";
#if SIZEOF_VOIDP == 4
if (memAllowed >= 4*1024)
{
[self cmdError: @"MemoryAllowed (%"PRIu64" too large for 32bit machine..."
@" using 0", memAllowed];
EcExceptionMajor(nil,
@"MemoryAllowed (%"PRIu64" too large for 32bit machine..."
@" using 0", memAllowed);
memAllowed = 0;
}
#endif
@ -2161,8 +2162,9 @@ static NSString *noFiles = @"No log files to archive";
#if SIZEOF_VOIDP == 4
if (memMaximum >= 4*1024)
{
[self cmdError: @"MemoryMaximum (%"PRIu64" too large for 32bit machine..."
@" using 0", memMaximum];
EcExceptionMajor(nil,
@"MemoryMaximum (%"PRIu64" too large for 32bit machine..."
@" using 0", memMaximum);
memMaximum = 0; // Disabled
}
#endif
@ -3261,17 +3263,17 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
[self cmdWarn: @"%@", message];
break;
case LT_ERROR:
[self cmdError: @"%@", message];
[[EcLogger loggerForType: LT_ERROR] log: @"%@", message];
break;
case LT_ALERT:
[self cmdAlert: @"%@", message];
[[EcLogger loggerForType: LT_ALERT] log: @"%@", message];
break;
case LT_AUDIT:
case LT_CONSOLE:
[self cmdAudit: @"%@", message];
break;
default:
[self cmdError: @"%@", message];
[[EcLogger loggerForType: LT_ERROR] log: @"%@", message];
break;
}
}
@ -3744,7 +3746,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
}
NS_HANDLER
{
[self cmdAlert: @"Problem running server: %@", localException];
EcExceptionCritical(localException, @"Problem running server");
[NSThread sleepForTimeInterval: 1.0];
}
NS_ENDHANDLER;
@ -5537,8 +5539,9 @@ With two parameters ('maximum' and a number),\n\
return [[server proxy] BCPproxy: count];
}
}
[self cmdError: @"Attempt to get %@ server for number %@ with bad config",
serverName, num];
EcExceptionMajor(nil,
@"Attempt to get %@ server for number %@ with bad config",
serverName, num);
return nil;
}
return [server proxy];