osaf/services/saf/logsv/README | 28 ++++++++-
osaf/services/saf/logsv/lgs/lgs_imm.c | 106 +++++++++++++++++++++++++--------
2 files changed, 107 insertions(+), 27 deletions(-)
Write configuration to syslog
diff --git a/osaf/services/saf/logsv/README b/osaf/services/saf/logsv/README
--- a/osaf/services/saf/logsv/README
+++ b/osaf/services/saf/logsv/README
@@ -143,10 +143,11 @@ Some implementation defined configuratio
Two ways of handling configuration is supported.
1. Configuration using a configuration object in IMM:
+----------------------------------------------------
When the LOG service is started it looks for a configuration object of
OpenSafLogConfig class. If an object is found and is correct the parameters in
the
object will be used. The configuration file as described in section 2 will not
-be used. The parameters in the object corresponds with the parameters described
+be used except according to 3. below. The parameters in the object corresponds
with the parameters described
in section 2. All parameters has a default value that is defined in the class
definition. By default an object of this class is created with the object name
"logConfig=1,safApp=safLogService" and no other attributes are set,
@@ -194,6 +195,7 @@ 1 Shared file system
2 Split file system
2. Configuration using a configuration file with environment variables:
+----------------------------------------------------------------------
This is the "old" way of handling configuration and is kept for backwards
compatibility and is used if no IMM configuration object is found .
The config file is typically:
@@ -248,6 +250,30 @@ The maximum number of application log st
Don't forget the "export" keyword before the variable!
+3. Precedence, special case
+---------------------------
+If any of the following attributes contains its default value of 0 and a
+corresponding environment variable is defined according to 2. the environment
+variable will be used.
+
+Config object attribute will be replaced by value of environment variable
+saLogStreamSystemHighLimit 0
LOG_STREAM_SYSTEM_HIGH_LIMIT
+saLogStreamSystemLowLimit 0 LOG_STREAM_SYSTEM_LOW_LIMIT
+saLogAppHighLimit 0 LOG_STREAM_APP_HIGH_LIMIT
+saLogAppLowLimit 0 LOG_STREAM_APP_LOW_LIMIT
+
+The attributes in the configuration object is not changed to reflect this.
+The configuration is logged in the syslog (messages)
+Example:
+...osaflogd[409]: NO Log config sys: hi 50001 lo 5001, app: hi 50002 lo 5002
+
+If an environment variable is defined and the corresponding config object
+attribute is not 0 the environment variable will not be used and a warning is
+logged.
+Example:
+...WA Log Configuration object 'logConfig=1,safApp=safLogService' exists
+...WA Ignoring environment variable LOG_STREAM_SYSTEM_HIGH_LIMIT
+
COMMAND LINE INTERFACE
diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.c
b/osaf/services/saf/logsv/lgs/lgs_imm.c
--- a/osaf/services/saf/logsv/lgs/lgs_imm.c
+++ b/osaf/services/saf/logsv/lgs/lgs_imm.c
@@ -1792,41 +1792,41 @@ static SaAisErrorT read_logsv_config_obj
lgsConf->logRootDirectory_noteflag = true;
}
param_cnt++;
- TRACE("logRootDirectory: %s",
lgsConf->logRootDirectory);
+ TRACE("Conf obj; logRootDirectory: %s",
lgsConf->logRootDirectory);
} else if (!strcmp(attribute->attrName, "logMaxLogrecsize")) {
lgsConf->logMaxLogrecsize = *((SaUint32T *) value);
param_cnt++;
- TRACE("logMaxLogrecsize: %u",
lgsConf->logMaxLogrecsize);
+ TRACE("Conf obj; logMaxLogrecsize: %u",
lgsConf->logMaxLogrecsize);
} else if (!strcmp(attribute->attrName,
"logStreamSystemHighLimit")) {
lgsConf->logStreamSystemHighLimit = *((SaUint32T *)
value);
param_cnt++;
- TRACE("logStreamSystemHighLimit: %u",
lgsConf->logStreamSystemHighLimit);
+ TRACE("Conf obj; logStreamSystemHighLimit: %u",
lgsConf->logStreamSystemHighLimit);
} else if (!strcmp(attribute->attrName,
"logStreamSystemLowLimit")) {
lgsConf->logStreamSystemLowLimit = *((SaUint32T *)
value);
param_cnt++;
- TRACE("logStreamSystemLowLimit: %u",
lgsConf->logStreamSystemLowLimit);
+ TRACE("Conf obj; logStreamSystemLowLimit: %u",
lgsConf->logStreamSystemLowLimit);
} else if (!strcmp(attribute->attrName,
"logStreamAppHighLimit")) {
lgsConf->logStreamAppHighLimit = *((SaUint32T *) value);
param_cnt++;
- TRACE("logStreamAppHighLimit: %u",
lgsConf->logStreamAppHighLimit);
+ TRACE("Conf obj; logStreamAppHighLimit: %u",
lgsConf->logStreamAppHighLimit);
} else if (!strcmp(attribute->attrName,
"logStreamAppLowLimit")) {
lgsConf->logStreamAppLowLimit = *((SaUint32T *) value);
param_cnt++;
- TRACE("logStreamAppLowLimit: %u",
lgsConf->logStreamAppLowLimit);
+ TRACE("Conf obj; logStreamAppLowLimit: %u",
lgsConf->logStreamAppLowLimit);
} else if (!strcmp(attribute->attrName,
"logMaxApplicationStreams")) {
lgsConf->logMaxApplicationStreams = *((SaUint32T *)
value);
param_cnt++;
- TRACE("logMaxApplicationStreams: %u",
lgsConf->logMaxApplicationStreams);
+ TRACE("Conf obj; logMaxApplicationStreams: %u",
lgsConf->logMaxApplicationStreams);
} else if (!strcmp(attribute->attrName, "logFileIoTimeout")) {
lgsConf->logFileIoTimeout = *((SaUint32T *) value);
lgsConf->logFileIoTimeout_noteflag = false;
param_cnt++;
- TRACE("logFileIoTimeout: %u",
lgsConf->logFileIoTimeout);
+ TRACE("Conf obj; logFileIoTimeout: %u",
lgsConf->logFileIoTimeout);
} else if (!strcmp(attribute->attrName, "logFileSysConfig")) {
lgsConf->logFileSysConfig = *((SaUint32T *) value);
lgsConf->logFileSysConfig_noteflag = false;
param_cnt++;
- TRACE("logFileSysConfig: %u",
lgsConf->logFileSysConfig);
+ TRACE("Conf obj; logFileSysConfig: %u",
lgsConf->logFileSysConfig);
}
}
@@ -2015,9 +2015,11 @@ static void read_logsv_config_environ_va
@ return none
*/
-void check_environs_for_configattribs(void)
+static void check_environs_for_configattribs(lgs_conf_t *lgsConf)
{
-
+ char *val_str;
+ unsigned long int val_uint;
+
/* If environment variables are configured then, print a warning
* message to syslog.
*/
@@ -2025,27 +2027,70 @@ void check_environs_for_configattribs(vo
LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
LOG_WA("Ignoring environment variable LOGSV_MAX_LOGRECSIZE");
}
-
- if (getenv("LOG_STREAM_SYSTEM_HIGH_LIMIT") != NULL) {
- LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
- LOG_WA("Ignoring environment variable
LOG_STREAM_SYSTEM_HIGH_LIMIT");
+
+ /* XXX CMWTMP Environment variables for limits are used if limits
+ * in configuration object is 0.
+ */
+ if ((val_str = getenv("LOG_STREAM_SYSTEM_HIGH_LIMIT")) != NULL) {
+ errno = 0;
+ val_uint = strtoul(val_str, NULL, 0);
+ if ((errno != 0) || (val_uint > UINT_MAX)) {
+ LOG_WA("Ignoring environment variable
LOG_STREAM_SYSTEM_HIGH_LIMIT");
+ LOG_WA("Illegal value");
+ } else if ((lgsConf->logStreamSystemHighLimit == 0) &&
+ (lgsConf->logStreamSystemLowLimit < val_uint)) {
+ lgsConf->logStreamSystemHighLimit = val_uint;
+ } else {
+ LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
+ LOG_WA("Ignoring environment variable
LOG_STREAM_SYSTEM_HIGH_LIMIT");
+ }
}
- if (getenv("LOG_STREAM_SYSTEM_LOW_LIMIT") != NULL) {
- LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
- LOG_WA("Ignoring environment variable
LOG_STREAM_SYSTEM_LOW_LIMIT");
+ if ((val_str = getenv("LOG_STREAM_SYSTEM_LOW_LIMIT")) != NULL) {
+ errno = 0;
+ val_uint = strtoul(val_str, NULL, 0);
+ if ((errno != 0) || (val_uint > UINT_MAX)) {
+ LOG_WA("Ignoring environment variable
LOG_STREAM_SYSTEM_LOW_LIMIT");
+ LOG_WA("Illegal value");
+ } else if ((lgsConf->logStreamSystemLowLimit == 0) &&
+ (lgsConf->logStreamSystemHighLimit > val_uint))
{
+ lgsConf->logStreamSystemLowLimit = val_uint;
+ } else {
+ LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
+ LOG_WA("Ignoring environment variable
LOG_STREAM_SYSTEM_LOW_LIMIT");
+ }
}
- if (getenv("LOG_STREAM_APP_HIGH_LIMIT") != NULL) {
- LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
- LOG_WA("Ignoring environment variable
LOG_STREAM_APP_HIGH_LIMIT");
+ if ((val_str = getenv("LOG_STREAM_APP_HIGH_LIMIT")) != NULL) {
+ errno = 0;
+ val_uint = strtoul(val_str, NULL, 0);
+ if ((errno != 0) || (val_uint > UINT_MAX)) {
+ LOG_WA("Ignoring environment variable
LOG_STREAM_APP_HIGH_LIMIT");
+ LOG_WA("Illegal value");
+ } else if ((lgsConf->logStreamAppHighLimit == 0) &&
+ (lgsConf->logStreamAppLowLimit < val_uint)) {
+ lgsConf->logStreamAppHighLimit = val_uint;
+ } else {
+ LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
+ LOG_WA("Ignoring environment variable
LOG_STREAM_APP_HIGH_LIMIT");
+ }
}
- if (getenv("LOG_STREAM_APP_LOW_LIMIT") != NULL) {
- LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
- LOG_WA("Ignoring environment variable
LOG_STREAM_APP_LOW_LIMIT");
+ if ((val_str = getenv("LOG_STREAM_APP_LOW_LIMIT")) != NULL) {
+ errno = 0;
+ val_uint = strtoul(val_str, NULL, 0);
+ if ((errno != 0) || (val_uint > UINT_MAX)) {
+ LOG_WA("Ignoring environment variable
LOG_STREAM_APP_LOW_LIMIT");
+ LOG_WA("Illegal value");
+ } else if ((lgsConf->logStreamAppLowLimit == 0) &&
+ (lgsConf->logStreamAppHighLimit > val_uint)) {
+ lgsConf->logStreamAppLowLimit = val_uint;
+ } else {
+ LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
+ LOG_WA("Ignoring environment variable
LOG_STREAM_APP_LOW_LIMIT");
+ }
}
-
+
if (getenv("LOG_MAX_APPLICATION_STREAMS") != NULL) {
LOG_WA("Log Configuration object '%s' exists",
LGS_IMM_LOG_CONFIGURATION);
LOG_WA("Ignoring environment variable
LOG_MAX_APPLICATION_STREAMS");
@@ -2088,10 +2133,19 @@ const void *lgs_imm_logconf_get(lgs_logc
/* LGS_IMM_LOG_CONFIGURATION object exists.
* If environment variables exists, then ignore them
* and log a message to syslog.
+ * For mailbox limits environment variables are used if
the
+ * value in configuration object is 0
*/
- check_environs_for_configattribs();
+ check_environs_for_configattribs(lgs_conf_p);
}
+ /* Write configuration to syslog */
+ LOG_NO("Log config sys: hi %d lo %d, app: hi %d lo %d",
+ lgs_conf->logStreamSystemHighLimit,
+ lgs_conf->logStreamSystemLowLimit,
+ lgs_conf->logStreamAppHighLimit,
+ lgs_conf->logStreamAppLowLimit);
+
lgs_conf_p->logInitiated = true;
}
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel