ACK ,
Mathi.

> -----Original Message-----
> From: giang do [mailto:[email protected]]
> Sent: Monday, August 31, 2015 11:32 AM
> To: Lennart Lund; Mathivanan Naickan Palanivelu;
> [email protected]
> Cc: [email protected]
> Subject: Re: [PATCH 1 of 1] log: Add logrec format tokens for time zone and
> millisec [#593]
> 
> Hi Vu,
> Tested and Acked from me.
> 
> Only some minor things that you could consider.
> Please see them in lines.
> 
> Best Regards,
> Giang Do
> 
> On 20/08/2015 22:49, Lennart Lund wrote:
> >   osaf/services/saf/logsv/README                   |   82 +++-
> >   osaf/services/saf/logsv/config/logsv_classes.xml |   11 +
> >   osaf/services/saf/logsv/lgs/lgs_config.c         |   70 +++-
> >   osaf/services/saf/logsv/lgs/lgs_config.h         |    3 +
> >   osaf/services/saf/logsv/lgs/lgs_evt.c            |    5 +-
> >   osaf/services/saf/logsv/lgs/lgs_fmt.c            |   70 +++-
> >   osaf/services/saf/logsv/lgs/lgs_fmt.h            |    8 +
> >   osaf/services/saf/logsv/lgs/lgs_imm.c            |   52 +-
> >   osaf/services/saf/logsv/lgs/lgs_mbcsv_v5.c       |    7 +-
> >   tests/logsv/logtest.c                            |   77 +++
> >   tests/logsv/logtest.h                            |    4 +
> >   tests/logsv/tet_LogOiOps.c                       |  469
> ++++++++++++++++++++++-
> >   12 files changed, 816 insertions(+), 42 deletions(-)
> >
> >
> > Add new tokens to show the offset between localtime/UTC timezone
> (@Cz and @Nz)
> > and show ms (3 digits) of logged time (@Ck and @Nk)
> >
> > Also, adding new attribute logStreamFileFormat to OpenSafLogConfig obj
> class.
> >
> > By this change, when opening a new application stream with logFileFmt set
> to NULL,
> > the file format for that stream is get from logStreamFileFormat attribute
> > which can be changed in run time.
> >
> > 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
> > @@ -173,15 +173,16 @@ The class defines the following paramete
> >   (logsv_classes.xml):
> >
> >   NAME                        DEFAULT VALUE         COMMENT
> > -saLogRootDirectory          $pkglogdir/saflog     Must be available in the 
> > file
> > +logRootDirectory            $pkglogdir/saflog     Must be available in the 
> > file
> >                                                     system
> > -saLogMaxLogrecsize          1024                  Max log record size 
> > including
> > +logMaxLogrecsize            1024                  Max log record size 
> > including
> >                                                     header information
> > -saLogStreamSystemHighLimit  0                     a.
> > -saLogStreamSystemLowLimit   0                     a.
> > -saLogAppHighLimit           0                     a.
> > -saLogAppLowLimit            0                     a.
> > -saLogMaxApplicationStreams  64                    Max number of application
> > +logStreamFileFormat         <empty>               c.
> > +logStreamSystemHighLimit    0                     a.
> > +logStreamSystemLowLimit     0                     a.
> > +logAppHighLimit             0                     a.
> > +logAppLowLimit              0                     a.
> > +logMaxApplicationStreams    64                    Max number of application
> >                                                     streams with runtime 
> > object
> >                                                     that can be created
> >   logFileIoTimeout            500                   File I/O timeout (see 
> > file.c)
> > @@ -192,13 +193,14 @@ a. Message queue thresholds used when qu
> >      different types
> >   b. Log service can be configured to write log records locally on both 
> > server
> >      nodes. This attribute cannot be changed in runtime
> > +c. The default format for application log records created using the log 
> > API.
> > +   If this attribute has no value <empty> a hard coded format as defined in
> the
> > +   log service AIS will be used as default format.
> >
> > -All the above attributes except saLogRootDirectory and
> logDataGroupname has a
> > -default value set in the class definition (see logsv_classes.xml). The 
> > value
> for
> > -parameter saLogRootDirectory is instead defined when the imm.xml file is
> created.
> > +A value for parameter saLogRootDirectory is instead defined when the
> imm.xml file is created.
> >   In the logsv_objects.xml file the parameter value is set to
> "xxLOGDIRxx/saflog"
> >   and when the imm.xml file is created "xxLOGDIRxx" is replaced by the
> content of
> > -$pkglogdir. See also LOGSV_ROOT_DIRECTORY in the logd.conf file.
> > +$pkglogdir.
> >
> >   The configuration file is still used to "enable trace" and
> >   "enable info level logging". Also the environment variable
> > @@ -206,15 +208,16 @@ LGSV_ENV_HEALTHCHECK_KEY is used.
> >
> >   The following attributes can be changed in runtime.
> >
> > - - saLogRootDirectory
> > + - logRootDirectory
> >      Can be changed to an existing path.
> >
> > - - saLogStreamSystemHighLimit
> > -   saLogStreamSystemLowLimit
> > -   saLogAppHighLimit
> > -   saLogAppLowLimit
> > -   Can be changed in runtime if both SC nodes supports changes. Could not
> > -   be changed in older versions.
> > + - logStreamFileFormat
> > +
> > + - logStreamSystemHighLimit
> > +   logStreamSystemLowLimit
> > +   logAppHighLimit
> > +   logAppLowLimit
> > +   Could not be changed in older versions.
> >
> >    - logDataGroupname
> >      Can be changed to an existing group which is currently a supplementary
> group
> > @@ -421,6 +424,23 @@ Functions that uses a "handler" has got
> >   e.g. fileopen(..) -> fileopen_h(..). All handlers can be found in file
> >   lgs_filehdl.c
> >
> > +Note on memory handling for writting log record:
> > +------------------------------------------------
> > +In most cases, the main thread is blocked until the log handler
> > +thread finishes the request (e.g: writing log record to file). Therefore,
> > +when the main thread is unblocked, it is safe to free the log record
> > +memory by the main thread as the log handler thread no longer uses it.
> > +
> > +But in time-out case, it is unsure when the log handler thread no longer
> uses
> > +the log record memory. So, in worse case, if the log record memory is
> freed
> > +by the main thread while the log handler is still using it, could cause the
> > +problem.
> > +
> > +To make sure there is no corruption of memory usage in case of time-out,
> > +leave the log record memory free to log handler thread.
> > +
> > +Refer to ticket #1376 for more info on this.
> > +
> >   File system configuration:
> >   When using UML (tools/cluster_sim_uml) the file system can be
> configured for
> >   both shared and split file system. This is done by setting the value of
> > @@ -665,3 +685,29 @@ On standby if configuration 2:
> >        previous record and the Id of the record to be written.
> >      - Write the check pointed log record.
> >
> > +LOG SERVICE ENHANCEMENTS
> > +========================
> > +
> > +1. New tokens are added (#593)
> > +------------------------------
> > +Currently, the log service presents the time in the local time settings.
> > +For example, if the log service is initiated in Stockholm, the log service
> > +shows the local Stockholm time.
> > +
> > +According to AIS standard, this time should be represented in UTC/GMT
> format.
> > +
> > +To cover this, new optional tokens are added to show "time zone" (@Cz,
> @Nz).
> > +- @Cz: for system and application log stream.
> > +- @Nz: for alarm and notification log stream.
> > +
> > +It should represent 04 numbers and an additional `+` or `-` sign in the
> beginning.
> > +Preceding and trailing zeros (0) if needed should exist.
> > +
> > +Format: [+,-]hhmm
> > +
> > +In addition, two more tokens are added to show three digits millisecond
> > +of second from log timestamp (@Ck, @Nk).
> > +- @Ck: for system and application log stream.
> > +- @Nk: for alarm and notification log stream.
> > +
> > +Preceding and trailing zeros (0) if needed should exist.
> > diff --git a/osaf/services/saf/logsv/config/logsv_classes.xml
> b/osaf/services/saf/logsv/config/logsv_classes.xml
> > --- a/osaf/services/saf/logsv/config/logsv_classes.xml
> > +++ b/osaf/services/saf/logsv/config/logsv_classes.xml
> > @@ -190,6 +190,12 @@ to ensure that default global values in
> >               <default-value>1024</default-value>
> >             </attr>
> >             <attr>
> > +                   <name>logStreamFileFormat</name>
> > +                   <type>SA_STRING_T</type>
> > +                   <category>SA_CONFIG</category>
> > +                   <flag>SA_WRITABLE</flag>
> > +           </attr>
> > +           <attr>
> >                     <name>logStreamSystemHighLimit</name>
> >                     <type>SA_UINT32_T</type>
> >                     <category>SA_CONFIG</category>
> > @@ -264,6 +270,11 @@ to ensure that default global values in
> >                     <category>SA_RUNTIME</category>
> >             </attr>
> >             <attr>
> > +                   <name>logStreamFileFormat</name>
> > +                   <type>SA_STRING_T</type>
> > +                   <category>SA_RUNTIME</category>
> > +           </attr>
> > +           <attr>
> >                     <name>logStreamSystemHighLimit</name>
> >                     <type>SA_UINT32_T</type>
> >                     <category>SA_RUNTIME</category>
> > diff --git a/osaf/services/saf/logsv/lgs/lgs_config.c
> b/osaf/services/saf/logsv/lgs/lgs_config.c
> > --- a/osaf/services/saf/logsv/lgs/lgs_config.c
> > +++ b/osaf/services/saf/logsv/lgs/lgs_config.c
> > @@ -35,6 +35,7 @@
> >   #include "logtrace.h"
> >   #include "immutil.h"
> >   #include "lgs_file.h"
> > +#include "lgs_fmt.h"
> >
> >   extern struct ImmutilWrapperProfile immutilWrapperProfile;
> >   static SaVersionT immVersion = { 'A', 2, 11 };
> > @@ -74,6 +75,7 @@ typedef struct {
> >     /* --- Corresponds to IMM Class SaLogConfig --- */
> >     char logRootDirectory[PATH_MAX];
> >     char logDataGroupname[UT_NAMESIZE];
> > +   char logStreamFileFormat[MAX_FIELD_SIZE];
> >     SaUint32T logMaxLogrecsize;
> >     SaUint32T logStreamSystemHighLimit;
> >     SaUint32T logStreamSystemLowLimit;
> > @@ -99,6 +101,7 @@ typedef struct {
> >     lgs_conf_flg_t logFileIoTimeout_cnfflag;
> >     lgs_conf_flg_t logFileSysConfig_cnfflag;
> >     lgs_conf_flg_t logDataGroupname_cnfflag;
> > +   lgs_conf_flg_t logStreamFileFormat_cnfflag;
> >   } lgs_conf_t;
> >
> >   /**
> > @@ -112,6 +115,7 @@ typedef struct {
> >   static struct {
> >     const char *logRootDirectory;
> >     const char *logDataGroupname;
> > +   const char *logStreamFileFormat;
> >     SaUint32T logStreamSystemHighLimit;
> >     SaUint32T logStreamSystemLowLimit;
> >     SaUint32T logStreamAppHighLimit;
> > @@ -125,6 +129,7 @@ static struct {
> >   } lgs_conf_def = {
> >     PKGLOGDIR,      /*logRootDirectory*/
> >     "",             /*logDataGroupname*/
> > +   DEFAULT_APP_SYS_FORMAT_EXP, /* logStreamFileFormat */
> >     1024,           /*logMaxLogrecsize*/
> >     0,              /*logStreamSystemHighLimit*/
> >     0,              /*logStreamSystemLowLimit*/
> > @@ -159,6 +164,7 @@ static lgs_conf_t lgs_conf = {
> >     .logMaxApplicationStreams_cnfflag = LGS_CNF_DEF,
> >     .logFileIoTimeout_cnfflag = LGS_CNF_DEF,
> >     .logFileSysConfig_cnfflag = LGS_CNF_DEF,
> > +   .logStreamFileFormat_cnfflag = LGS_CNF_DEF,
> >   };
> >
> >
> > @@ -180,6 +186,7 @@ static void init_default(void)
> >   {
> >     (void) strcpy(lgs_conf.logRootDirectory,
> lgs_conf_def.logRootDirectory);
> >     (void) strcpy(lgs_conf.logDataGroupname,
> lgs_conf_def.logDataGroupname);
> > +   (void) strcpy(lgs_conf.logStreamFileFormat,
> lgs_conf_def.logStreamFileFormat);
> >     lgs_conf.logMaxLogrecsize = lgs_conf_def.logMaxLogrecsize;
> >     lgs_conf.logStreamSystemHighLimit =
> lgs_conf_def.logStreamSystemHighLimit;
> >     lgs_conf.logStreamSystemLowLimit =
> lgs_conf_def.logStreamSystemLowLimit;
> > @@ -388,6 +395,10 @@ int lgs_cfg_update(const lgs_config_chg_
> >                     (void) snprintf(lgs_conf.logDataGroupname,
> UT_NAMESIZE,
> >                             "%s", value_str);
> >                     lgs_conf.logDataGroupname_cnfflag =
> LGS_CNF_OBJ;
> > +           } else if (strcmp(name_str, LOG_STREAM_FILE_FORMAT) ==
> 0) {
> > +                   (void) snprintf(lgs_conf.logStreamFileFormat,
> MAX_FIELD_SIZE,
> > +                                                   "%s", value_str);
> > +                   lgs_conf.logStreamFileFormat_cnfflag =
> LGS_CNF_OBJ;
> >             } else if (strcmp(name_str, LOG_MAX_LOGRECSIZE) == 0) {
> >                     lgs_conf.logMaxLogrecsize = (SaUint32T)
> >                             strtoul(value_str, NULL, 0);
> > @@ -507,6 +518,30 @@ int lgs_cfg_verify_log_data_groupname(ch
> >   }
> >
> >   /**
> > + * Verify logStreamFileFormat attribute value of App stream.
> > + * Rule:
> > + *   All tokens are in right format
> > + *
> > + * @param log_file_format [in]
> > + * @return -1 on error
> > + */
> > +int lgs_cfg_verify_log_file_format(const char* log_file_format)
> > +{
> > +   int rc = 0;
> > +   SaBoolT dummy;
> > +
> > +   if (!lgs_is_valid_format_expression((const SaStringT)log_file_format,
> > +
>       STREAM_TYPE_APPLICATION,
> > +
>       &dummy)) {
> > +           LOG_NO("logStreamFileFormat has invalid value = %s",
> > +                      log_file_format);
> > +           rc = -1;
> > +   }
> > +
> > +   return rc;
> > +}
> > +
> > +/**
> >    * Verify logMaxLogrecsize; Max size of a log record including header
> >    * Rules:
> >    * - Because of an incorrect declaration in the server (uint16_t) that 
> > shall
> be
> > @@ -659,6 +694,12 @@ static int verify_all_init(void)
> >             rc = -1;
> >     }
> >
> > +   if (lgs_cfg_verify_log_file_format(lgs_conf.logStreamFileFormat) ==
> -1) {
> > +           strcpy(lgs_conf.logStreamFileFormat,
> lgs_conf_def.logStreamFileFormat);
> > +           lgs_conf.logStreamFileFormat_cnfflag = LGS_CNF_DEF;
> > +           rc = -1;
> > +   }
> > +
> >     if (lgs_cfg_verify_max_logrecsize(lgs_conf.logMaxLogrecsize) == -1)
> {
> >             lgs_conf.logMaxLogrecsize = lgs_conf_def.logMaxLogrecsize;
> >             lgs_conf.logMaxLogrecsize_cnfflag = LGS_CNF_DEF;
> > @@ -789,6 +830,19 @@ static void read_logsv_config_obj_2(void
> >                             TRACE("Conf obj; logDataGroupname: %s",
> >                                     lgs_conf.logDataGroupname);
> >                     }
> > +           } else if (!strcmp(attribute->attrName,
> LOG_STREAM_FILE_FORMAT)) {
> > +                   n = snprintf(lgs_conf.logStreamFileFormat,
> MAX_FIELD_SIZE, "%s",
> > +                                            *((char **) value));
> > +                   if (n >= MAX_FIELD_SIZE) {
> > +                           /* The attribute has invalid value - use
> default value instead */
> > +                           LOG_NO("Invalid logStreamFileFormat: %s",
> > +                                      lgs_conf.logStreamFileFormat);
> > +                           lgs_conf.logStreamFileFormat[0] = '\0';
> > +                   } else {
> > +                           lgs_conf.logStreamFileFormat_cnfflag =
> LGS_CNF_OBJ;
> > +                           TRACE("Conf obj; %s: %s", attribute-
> >attrName,
> > +                                     lgs_conf.logStreamFileFormat);
> > +                   }
> >             } else if (!strcmp(attribute->attrName,
> LOG_MAX_LOGRECSIZE)) {
> >                     lgs_conf.logMaxLogrecsize = *((SaUint32T *) value);
> >                     lgs_conf.logMaxLogrecsize_cnfflag = LGS_CNF_OBJ;
> > @@ -1192,6 +1246,9 @@ const void *lgs_cfg_get(lgs_logconfGet_t
> >     case LGS_IMM_DATA_GROUPNAME:
> >             value_ptr = lgs_conf.logDataGroupname;
> >             break;
> > +   case LGS_IMM_LOG_STREAM_FILE_FORMAT:
> > +           value_ptr = lgs_conf.logStreamFileFormat;
> > +           break;
> >     case LGS_IMM_LOG_MAX_LOGRECSIZE:
> >             value_ptr = &lgs_conf.logMaxLogrecsize;
> >             break;
> > @@ -1423,6 +1480,13 @@ void conf_runtime_obj_hdl(SaImmOiHandleT
> >                             LGS_CFG_RUNTIME_OBJECT,
> >                             attributeName, SA_IMM_ATTR_SASTRINGT,
> >                             &str_val);
> > +           } else if (!strcmp(attributeName,
> LOG_STREAM_FILE_FORMAT)) {
> > +                   str_val = (char *)
> > +
>       lgs_cfg_get(LGS_IMM_LOG_STREAM_FILE_FORMAT);
> > +                   (void)immutil_update_one_rattr(immOiHandle,
> > +                      LGS_CFG_RUNTIME_OBJECT,
> > +                      attributeName, SA_IMM_ATTR_SASTRINGT,
> > +                      &str_val);
> >             } else if (!strcmp(attributeName, LOG_MAX_LOGRECSIZE)) {
> >                     u32_val = *(SaUint32T *)
> >
>       lgs_cfg_get(LGS_IMM_LOG_MAX_LOGRECSIZE);
> > @@ -1521,6 +1585,9 @@ void lgs_trace_config(void)
> >     TRACE("logDataGroupname\t\t \"%s\",\t %s",
> >             lgs_conf.logDataGroupname,
> >             cnfflag_str(lgs_conf.logDataGroupname_cnfflag));
> > +   TRACE("logStreamFileFormat\t\t \"%s\",\t %s",
> > +             lgs_conf.logStreamFileFormat,
> > +             cnfflag_str(lgs_conf.logStreamFileFormat_cnfflag));
> >     TRACE("logMaxLogrecsize\t\t %u,\t %s",
> >             lgs_conf.logMaxLogrecsize,
> >             cnfflag_str(lgs_conf.logMaxLogrecsize_cnfflag));
> > @@ -1561,6 +1628,7 @@ void lgs_cfg_read_trace(void)
> >     TRACE("##### LOG Configuration parameter read start #####");
> >     TRACE("logRootDirectory\t\t \"%s\"", (char *)
> lgs_cfg_get(LGS_IMM_LOG_ROOT_DIRECTORY));
> >     TRACE("logDataGroupname\t\t \"%s\"", (char *)
> lgs_cfg_get(LGS_IMM_DATA_GROUPNAME));
> > +   TRACE("logStreamFileFormat\t\t \"%s\"", (char *)
> lgs_cfg_get(LGS_IMM_LOG_STREAM_FILE_FORMAT));
> >     TRACE("logMaxLogrecsize\t\t %u", *(SaUint32T *)
> lgs_cfg_get(LGS_IMM_LOG_MAX_LOGRECSIZE));
> >     TRACE("logStreamSystemHighLimit\t %u", *(SaUint32T *)
> lgs_cfg_get(LGS_IMM_LOG_STREAM_SYSTEM_HIGH_LIMIT));
> >     TRACE("logStreamSystemLowLimit\t %u", *(SaUint32T *)
> lgs_cfg_get(LGS_IMM_LOG_STREAM_SYSTEM_LOW_LIMIT));
> > @@ -1570,4 +1638,4 @@ void lgs_cfg_read_trace(void)
> >     TRACE("logFileIoTimeout\t\t %u", *(SaUint32T *)
> lgs_cfg_get(LGS_IMM_FILEHDL_TIMEOUT));
> >     TRACE("logFileSysConfig\t\t %u", *(SaUint32T *)
> lgs_cfg_get(LGS_IMM_LOG_FILESYS_CFG));
> >     TRACE("##### LOG Configuration parameter read done  #####");
> > -}
> > \ No newline at end of file
> > +}
> > diff --git a/osaf/services/saf/logsv/lgs/lgs_config.h
> b/osaf/services/saf/logsv/lgs/lgs_config.h
> > --- a/osaf/services/saf/logsv/lgs/lgs_config.h
> > +++ b/osaf/services/saf/logsv/lgs/lgs_config.h
> > @@ -32,6 +32,7 @@ extern "C" {
> >   #define LOG_ROOT_DIRECTORY "logRootDirectory"
> >   #define LOG_DATA_GROUPNAME "logDataGroupname"
> >   #define LOG_MAX_LOGRECSIZE "logMaxLogrecsize"
> > +#define LOG_STREAM_FILE_FORMAT "logStreamFileFormat"
> >   #define LOG_STREAM_SYSTEM_HIGH_LIMIT "logStreamSystemHighLimit"
> >   #define LOG_STREAM_SYSTEM_LOW_LIMIT "logStreamSystemLowLimit"
> >   #define LOG_STREAM_APP_HIGH_LIMIT "logStreamAppHighLimit"
> > @@ -44,6 +45,7 @@ typedef enum {
> >     LGS_IMM_LOG_ROOT_DIRECTORY,
> >     LGS_IMM_DATA_GROUPNAME,
> >     LGS_IMM_LOG_MAX_LOGRECSIZE,
> > +   LGS_IMM_LOG_STREAM_FILE_FORMAT,
> >     LGS_IMM_LOG_STREAM_SYSTEM_HIGH_LIMIT,
> >     LGS_IMM_LOG_STREAM_SYSTEM_LOW_LIMIT,
> >     LGS_IMM_LOG_STREAM_APP_HIGH_LIMIT,
> > @@ -91,6 +93,7 @@ void lgs_groupnameconf_set(const char *d
> >    */
> >   int lgs_cfg_verify_root_dir(char *root_str_in);
> >   int lgs_cfg_verify_log_data_groupname(char *group_name);
> > +int lgs_cfg_verify_log_file_format(const char* log_file_format);
> >   int lgs_cfg_verify_max_logrecsize(uint32_t max_logrecsize_in);
> >   int lgs_cfg_verify_mbox_limit(uint32_t high, uint32_t low);
> >   int lgs_cfg_verify_max_application_streams(uint32_t max_app_streams);
> > diff --git a/osaf/services/saf/logsv/lgs/lgs_evt.c
> b/osaf/services/saf/logsv/lgs/lgs_evt.c
> > --- a/osaf/services/saf/logsv/lgs/lgs_evt.c
> > +++ b/osaf/services/saf/logsv/lgs/lgs_evt.c
> > @@ -798,8 +798,9 @@ static SaAisErrorT create_new_app_stream
> >     }
> >
> >     if (open_sync_param->logFileFmt == NULL) {
> > -           TRACE("Assigning default format string for app stream");
> > -           open_sync_param->logFileFmt =
> strdup(DEFAULT_APP_SYS_FORMAT_EXP);
> > +           TRACE("logFileFmt is NULL, use default one");
> > +           const char* logFileFormat = (char *)
> lgs_cfg_get(LGS_IMM_LOG_STREAM_FILE_FORMAT);
> > +           open_sync_param->logFileFmt = strdup(logFileFormat);
> >     }
> >
> >     /* Check the format string */
> > diff --git a/osaf/services/saf/logsv/lgs/lgs_fmt.c
> b/osaf/services/saf/logsv/lgs/lgs_fmt.c
> > --- a/osaf/services/saf/logsv/lgs/lgs_fmt.c
> > +++ b/osaf/services/saf/logsv/lgs/lgs_fmt.c
> > @@ -25,6 +25,10 @@
> >   #include <ncsgl_defs.h>
> >   #include "lgs_fmt.h"
> >
> > +/* Number of seconds per an hour/minute */
> > +#define SECOND_PER_HOUR  3600L
> > +#define SECOND_PER_MINUTE 60L
> > +
> >   /**
> >    *
> >    * @param inputString
> > @@ -181,6 +185,24 @@ static SaBoolT validateComToken(SaString
> >             }
> >             break;
> >
> > +   case C_TIME_MILLISECOND_LETTER:
> > +           shiftOffset = (int) C_TIME_MILLISECOND_SHIFT_OFFSET;
> > +           if ((SaBoolT)((*tokenFlags >> shiftOffset) & 1) == SA_TRUE) {
> > +                   tokenOk = SA_FALSE;     /* Same token used two
> times */
> > +           } else {
> > +                   *tokenFlags = (*tokenFlags | (1 << shiftOffset));
> > +           }
> > +           break;
> > +
> > +   case C_TIME_TIMEZONE_LETTER:
> > +           shiftOffset = (int) C_TIME_TIMEZONE_SHIFT_OFFSET;
> > +           if ((SaBoolT)((*tokenFlags >> shiftOffset) & 1) == SA_TRUE) {
> > +                   tokenOk = SA_FALSE;     /* Same token used two
> times */
> > +           } else {
> > +                   *tokenFlags = (*tokenFlags | (1 << shiftOffset));
> > +           }
> > +           break;
> > +
> >     case C_NOTIFICATION_CLASS_ID_LETTER:
> >             shiftOffset =
> (int)C_NOTIFICATION_CLASS_ID_SHIFT_OFFSET;
> >             if ((SaBoolT)((*tokenFlags >> shiftOffset) & 1) == SA_TRUE) {
> > @@ -368,6 +390,24 @@ static SaBoolT validateNtfToken(SaString
> >             }
> >             break;
> >
> > +   case N_EVENT_TIME_MILLISECOND_LETTER:
> > +           shiftOffset = (int)
> N_EVENT_TIME_MILLISECOND_SHIFT_OFFSET;
> > +           if ((SaBoolT)((*tokenFlags >> shiftOffset) & 1) == SA_TRUE) {
> > +                   tokenOk = SA_FALSE;     /* Same token used two
> times */
> > +           } else {
> > +                   *tokenFlags = (*tokenFlags | (1 << shiftOffset));
> > +           }
> > +           break;
> > +
> > +   case N_EVENT_TIME_TIMEZONE_LETTER:
> > +           shiftOffset = (int)
> N_EVENT_TIME_TIMEZONE_SHIFT_OFFSET;
> > +           if ((SaBoolT)((*tokenFlags >> shiftOffset) & 1) == SA_TRUE) {
> > +                   tokenOk = SA_FALSE;     /* Same token used two
> times */
> > +           } else {
> > +                   *tokenFlags = (*tokenFlags | (1 << shiftOffset));
> > +           }
> > +           break;
> > +
> >     case N_EVENT_TYPE_LETTER:
> >             shiftOffset = (int)N_EVENT_TYPE_SHIFT_OFFSET;
> >             if ((SaBoolT)((*tokenFlags >> shiftOffset) & 1) == SA_TRUE) {
> > @@ -601,7 +641,7 @@ static int extractCommonField(char *dest
> >             }
> >
> >             break;
> > -
> > +
> >     case C_TIME_STAMP_DAY_LETTER:
> >             stringSize = 3 * sizeof(char);
> >             characters = snprintf(dest, dest_size, "%02d",
> (timeStampData->tm_mday));
> > @@ -654,6 +694,21 @@ static int extractCommonField(char *dest
> >             characters = strftime(dest, dest_size, "%Y", timeStampData);
> >             break;
> >
> > +   case C_TIME_MILLISECOND_LETTER:
> > +           stringSize = 4 * sizeof(char);
> > +           /* Extract millisecond from logTimestamp */
> > +           SaTimeT us = logRecord->logTimeStamp /
> SA_TIME_ONE_MICROSECOND;
> > +           characters = snprintf(dest, dest_size, "%03lld", us %
> SA_TIME_ONE_MICROSECOND);
> > +           break;
> > +
> > +   case C_TIME_TIMEZONE_LETTER:
> > +           stringSize = 6 * sizeof(char);
> > +           /* Get timezone offset from localtime to UTC time */
> > +           long gmtOffset = (timeStampData->tm_gmtoff /
> SECOND_PER_HOUR) * 100 +
> > +                   (timeStampData->tm_gmtoff %
> SECOND_PER_HOUR) / SECOND_PER_MINUTE;
> > +           characters = snprintf(dest, dest_size, "%c%04ld", gmtOffset
> >= 0 ? '+' : '-', gmtOffset);
> > +           break;
> > +
> >     case C_NOTIFICATION_CLASS_ID_LETTER:
> >             stringSize = 30 * sizeof(char);
> >             if (logRecord->logHdrType == SA_LOG_GENERIC_HEADER) {
> > @@ -917,6 +972,19 @@ static int extractNotificationField(char
> >             characters = snprintf(dest, dest_size, "%d", (eventTimeData-
> >tm_year + START_YEAR));
> >             break;
> >
> > +   case N_EVENT_TIME_MILLISECOND_LETTER:
> > +           /* Extract millisecond from logTimestamp */
> > +           characters = snprintf(dest, dest_size, "%03lld", totalTime %
> SA_TIME_ONE_MICROSECOND);
> > +           break;
> > +
> > +   case N_EVENT_TIME_TIMEZONE_LETTER:
> > +           /* Get time offset from localtime to UTC */
> > +           characters = 6; /* to avoid using {} */
> > +           long gmtOffset = (eventTimeData->tm_gmtoff /
> SECOND_PER_HOUR) * 100 +
> > +                   (eventTimeData->tm_gmtoff %
> SECOND_PER_HOUR) / SECOND_PER_MINUTE;
> > +           characters = snprintf(dest, dest_size, "%c%04ld", gmtOffset
> >= 0 ? '+' : '-', gmtOffset);
> > +           break;
> > +
> >     case N_EVENT_TYPE_LETTER:
> >             /* Check field size */
> >             fieldSize = checkFieldSize(fmtExpPtr, &fieldSizeOffset);
> > diff --git a/osaf/services/saf/logsv/lgs/lgs_fmt.h
> b/osaf/services/saf/logsv/lgs/lgs_fmt.h
> > --- a/osaf/services/saf/logsv/lgs/lgs_fmt.h
> > +++ b/osaf/services/saf/logsv/lgs/lgs_fmt.h
> > @@ -49,6 +49,8 @@ typedef enum {
> >     C_TIME_STAMP_DAYN_SHIFT_OFFSET,
> >     C_TIME_STAMP_YEAR_SHIFT_OFFSET,
> >     C_TIME_STAMP_FULL_YEAR_SHIFT_OFFSET,
> > +   C_TIME_MILLISECOND_SHIFT_OFFSET,
> > +   C_TIME_TIMEZONE_SHIFT_OFFSET,
> >     C_NOTIFICATION_CLASS_ID_SHIFT_OFFSET,
> >     C_LR_TRUNCATION_INFO_SHIFT_OFFSET,
> >     C_LR_STRING_BODY_SHIFT_OFFSET,
> > @@ -68,6 +70,8 @@ typedef enum {
> >     N_EVENT_TIME_DAYN_SHIFT_OFFSET,
> >     N_EVENT_TIME_YEAR_SHIFT_OFFSET,
> >     N_EVENT_TIME_FULL_YEAR_SHIFT_OFFSET,
> > +   N_EVENT_TIME_MILLISECOND_SHIFT_OFFSET,
> > +   N_EVENT_TIME_TIMEZONE_SHIFT_OFFSET,
> >     N_EVENT_TYPE_SHIFT_OFFSET,
> >     N_NOTIFICATION_OBJECT_SHIFT_OFFSET,
> >     N_NOTIFYING_OBJECT_SHIFT_OFFSET
> > @@ -91,6 +95,8 @@ typedef enum {
> >     C_TIME_STAMP_DAYN_LETTER = 'D',
> >     C_TIME_STAMP_YEAR_LETTER = 'y',
> >     C_TIME_STAMP_FULL_YEAR_LETTER = 'Y',
> > +   C_TIME_MILLISECOND_LETTER = 'k',
> > +   C_TIME_TIMEZONE_LETTER = 'z',
> >     C_NOTIFICATION_CLASS_ID_LETTER = 'c',
> >     C_LR_TRUNCATION_INFO_LETTER = 'x',
> >     C_LR_STRING_BODY_LETTER = 'b',
> > @@ -110,6 +116,8 @@ typedef enum {
> >     N_EVENT_TIME_DAYN_LETTER = 'D',
> >     N_EVENT_TIME_YEAR_LETTER = 'y',
> >     N_EVENT_TIME_FULL_YEAR_LETTER = 'Y',
> > +   N_EVENT_TIME_MILLISECOND_LETTER = 'k',
> > +   N_EVENT_TIME_TIMEZONE_LETTER = 'z',
> >     N_EVENT_TYPE_LETTER = 'e',
> >     N_NOTIFICATION_OBJECT_LETTER = 'o',
> >     N_NOTIFYING_OBJECT_LETTER = 'g'
> > 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
> > @@ -760,6 +760,17 @@ static SaAisErrorT config_ccb_completed_
> >                             }
> >                             TRACE("groupname: %s is accepted",
> groupname);
> >                     }
> > +           } else if (!strcmp(attribute->attrName,
> LOG_STREAM_FILE_FORMAT)) {
> > +                   char *logFileFormat = *((char **) value);
> > +                   rc = lgs_cfg_verify_log_file_format(logFileFormat);
> > +                   if (rc == -1) {
> > +                           report_oi_error(immOiHandle, opdata-
> >ccbId,
> > +                                                           "%s value is
> NOT accepted", attribute->attrName);
> > +                           ais_rc = SA_AIS_ERR_INVALID_PARAM;
> > +                           goto done;
> > +                   }
> > +                   TRACE("%s value is accepted", logFileFormat);
> [Giang] should change to TRACE("logFileFormat: %s is accepted",
> logFileFormat). It will help people recognize easier this value is
> logFileFormat.
> > +                   goto done;
> >             } else if (!strcmp(attribute->attrName,
> LOG_MAX_LOGRECSIZE)) {
> >                     report_oi_error(immOiHandle, opdata->ccbId,
> >                                     "%s cannot be changed", attribute-
> >attrName);
> > @@ -1923,6 +1934,14 @@ static void config_ccb_apply_modify(cons
> >                     apply_conf_logDataGroupname(value_str);
> >                     lgs_cfgupd_list_create(LOG_DATA_GROUPNAME,
> >                             value_str, &config_data);
> > +           } else if (!strcmp(attribute->attrName,
> LOG_STREAM_FILE_FORMAT)) {
> > +                   /**
> > +                    * This attribute value is used for default log file
> format of
> > +                    * app stream. Changing this value don't result in
> cfg/log file creation.
> > +                   */
> > +                   value_str = *((char **)value);
> > +                   lgs_cfgupd_list_create(LOG_STREAM_FILE_FORMAT,
> > +                            value_str, &config_data);
> >             } else if (!strcmp(attribute->attrName,
> LOG_STREAM_SYSTEM_HIGH_LIMIT)) {
> >                     uint32_val = *(uint32_t *) value;
> >                     snprintf(uint32_str, 20, "%u", uint32_val);
> > @@ -2082,9 +2101,8 @@ static SaAisErrorT stream_create_and_con
> >                             char *logFileFormat = *((char **) value);
> >                             if
> (!lgs_is_valid_format_expression(logFileFormat, (*stream)->streamType,
> &dummy)) {
> >                                     LOG_WA("Invalid logFileFormat for
> stream %s, using default", (*stream)->name);
> > -                                   logFileFormat =
> DEFAULT_APP_SYS_FORMAT_EXP;
> > +                                   logFileFormat = (char *)
> lgs_cfg_get(LGS_IMM_LOG_STREAM_FILE_FORMAT);
> >                             }
> > -
> >                             (*stream)->logFileFormat =
> strdup(logFileFormat);
> >                             TRACE("logFileFormat: %s", (*stream)-
> >logFileFormat);
> >                     } else if (!strcmp(ccb->param.create.attrValues[i]-
> >attrName, "saLogStreamSeverityFilter")) {
> > @@ -2095,8 +2113,11 @@ static SaAisErrorT stream_create_and_con
> >             i++;
> >     } // while
> >
> > -   if ((*stream)->logFileFormat == NULL)
> > -           (*stream)->logFileFormat =
> strdup(log_file_format[(*stream)->streamType]);
> > +   if ((*stream)->logFileFormat == NULL) {
> > +           /* If passing NULL to log file format, use default value */
> > +           const char* logFileFormat = (char *)
> lgs_cfg_get(LGS_IMM_LOG_STREAM_FILE_FORMAT);
> > +           (*stream)->logFileFormat = strdup(logFileFormat);
> > +   }
> >
> >     /* Update creation timestamp */
> >     (void) immutil_update_one_rattr(lgs_cb->immOiHandle, (const
> char*) objectName.value,
> > @@ -2507,15 +2528,12 @@ static SaAisErrorT stream_create_and_con
> >                     if (!lgs_is_valid_format_expression(logFileFormat,
> stream->streamType, &dummy)) {
> >                             LOG_WA("Invalid logFileFormat for stream
> %s, using default", stream->name);
> >
> > -                           if ((stream->streamType ==
> STREAM_TYPE_SYSTEM) ||
> > -                               (stream->streamType ==
> STREAM_TYPE_APPLICATION))
> > -                                   logFileFormat =
> DEFAULT_APP_SYS_FORMAT_EXP;
> > -
> > -                           if ((stream->streamType ==
> STREAM_TYPE_ALARM) ||
> > -                               (stream->streamType ==
> STREAM_TYPE_NOTIFICATION))
> > -                                   logFileFormat =
> DEFAULT_ALM_NOT_FORMAT_EXP;
> > +                           if (stream->streamType ==
> STREAM_TYPE_APPLICATION) {
> > +                                   logFileFormat = (char *)
> lgs_cfg_get(LGS_IMM_LOG_STREAM_FILE_FORMAT);
> > +                           } else {
> > +                                   strcpy(logFileFormat,
> log_file_format[stream->streamType]);
> > +                           }
> >                     }
> > -
> >                     stream->logFileFormat = strdup(logFileFormat);
> >                     TRACE("logFileFormat: %s", stream->logFileFormat);
> >             } else if (!strcmp(attribute->attrName,
> "saLogStreamSeverityFilter")) {
> > @@ -2524,8 +2542,14 @@ static SaAisErrorT stream_create_and_con
> >             }
> >     }
> >
> > -   if (stream->logFileFormat == NULL)
> > -           stream->logFileFormat = strdup(log_file_format[stream-
> >streamType]);
> > +   if (stream->logFileFormat == NULL) {
> > +           if (stream->streamType == STREAM_TYPE_APPLICATION) {
> > +                   const char* logFileFormat = (char *)
> lgs_cfg_get(LGS_IMM_LOG_STREAM_FILE_FORMAT);
> > +                   stream->logFileFormat = strdup(logFileFormat);
> > +           } else {
> > +                   stream->logFileFormat =
> strdup(log_file_format[stream->streamType]);
> > +           }
> > +   }
> >
> >    done:
> >     TRACE_LEAVE();
> > diff --git a/osaf/services/saf/logsv/lgs/lgs_mbcsv_v5.c
> b/osaf/services/saf/logsv/lgs/lgs_mbcsv_v5.c
> > --- a/osaf/services/saf/logsv/lgs/lgs_mbcsv_v5.c
> > +++ b/osaf/services/saf/logsv/lgs/lgs_mbcsv_v5.c
> > @@ -39,7 +39,10 @@
> >    *
> >    * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
> >    *
> > - * Notes         : None.
> > + * Notes         : The configuration store on standby must always be 
> > updated
> > + *                 when there are changes in log service configuration.
> > + *                 This is done by calling lgs_cfg_update() function.
> > + *
> >
> **********************************************************
> ******************/
> >
> >   uint32_t ckpt_proc_lgs_cfg_v5(lgs_cb_t *cb, void *data)
> > @@ -87,6 +90,8 @@ uint32_t ckpt_proc_lgs_cfg_v5(lgs_cb_t *
> >                     &cfg_buffer);
> >
> >     while (next_ptr != NULL) {
> > +           /* Attribute changes that needs more than to be updated in
> the
> > +            * configuration store are handled here */
> >             if ((strcmp(name_str, LOG_ROOT_DIRECTORY) == 0) &&
> >                 (lgs_is_split_file_system() == true)){
> >                     const char *new_root_path = value_str;
> > diff --git a/tests/logsv/logtest.c b/tests/logsv/logtest.c
> > --- a/tests/logsv/logtest.c
> > +++ b/tests/logsv/logtest.c
> > @@ -64,6 +64,12 @@ SaNameT notificationObject =
> >       .length = sizeof(DEFAULT_NOTIFICATION_OBJECT)
> >   };
> >
> > +SaNameT configurationObject =
> > +{
> > +   .value = SA_LOG_CONFIGURATION_OBJECT,
> > +   .length = sizeof(SA_LOG_CONFIGURATION_OBJECT)
> > +};
> > +
> >   SaNameT saNameT_Object_256 =
> >   {
> >       .value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
> > @@ -182,6 +188,77 @@ void init_logrootpath(void)
> >     (void) immutil_saImmOmFinalize(omHandle);
> >   }
> >
> > +
> > +/**
> > + * Get attribute value in string from IMM
> > + * @param inObjname Distinguished Name
> > + * @param inAttr Attribute to search for value
> > + * @param outNume The holder for the output for number data type
> attribute
> > + * @param outvalue The holder for the output for string data type
> attribute
> > + * @return 0 if successfull, otherwise (-1)
> > + */
> > +int get_attr_value(SaNameT *inObjName, char *inAttr, void **outNum,
> > +   char* outStr)
> > +{
> > +   SaImmHandleT omHandle;
> > +   SaImmAccessorHandleT accessorHandle;
> > +   SaImmAttrValuesT_2 *attribute = NULL;
> > +   SaImmAttrValuesT_2 **attributes;
> > +   SaAisErrorT ais_rc = SA_AIS_OK;
> > +   SaImmAttrNameT attributeNames[2] = {inAttr, NULL};
> > +   void *value;
> > +   static uint64_t g_val = 0;
> > +   int rc = 0;
> > +
> > +   /* NOTE: immutil init osaf_assert if error */
> > +   (void) immutil_saImmOmInitialize(&omHandle, NULL,
> &immVersion);
> > +   (void) immutil_saImmOmAccessorInitialize(omHandle,
> &accessorHandle);
> > +
> > +   /* Get all attributes of the object */
> > +   ais_rc = immutil_saImmOmAccessorGet_2(accessorHandle,
> inObjName, attributeNames, &attributes);
> > +   if (ais_rc == SA_AIS_OK) {
> > +           attribute = attributes[0];
> > +           /* Return error if the attribute have not been initialized yet
> */
> > +           if (attribute == NULL) return (-1);
> > +
> > +           /* Value is empty */
> > +           if (attribute->attrValuesNumber == 0) return (-1);
> > +
> > +           /**
> > +            * Seperate processing for 2 kinds of data type -
> string/numbers (uint32/uint64).
> > +            */
> > +           value = attribute->attrValues[0];
> > +           if (!strcmp(inAttr, "logMaxLogrecsize") ||
> > +                   !strcmp(inAttr, "logMaxApplicationStreams") ||
> > +                   !strcmp(inAttr, "logFileIoTimeout") ||
> > +                   !strcmp(inAttr, "logStreamSystemLowLimit") ||
> > +                   !strcmp(inAttr, "logStreamSystemHighLimit") ||
> > +                   !strcmp(inAttr, "logStreamAppLowLimit") ||
> > +                   !strcmp(inAttr, "logStreamAppHighLimit") ||
> > +                   !strcmp(inAttr, "logFileSysConfig") ||
> > +                   !strcmp(inAttr, "saLogStreamMaxLogFileSize") ||
> > +                   !strcmp(inAttr, "saLogStreamLogFullHaltThreshold")
> ||
> > +                   !strcmp(inAttr, "saLogStreamLogFullAction") ||
> > +                   !strcmp(inAttr, "saLogStreamFixedLogRecordSize")
> ||
> > +                   !strcmp(inAttr, "saLogStreamSeverityFilter") ||
> > +                   !strcmp(inAttr, "saLogStreamMaxFilesRotated")) {
> > +                    /* uint32_t/uint64_t data type */
> > +                   g_val = *(SaUint64T *) value;
> > +                   *outNum = &g_val;
> > +           } else {
> > +                   /* String data type */
> > +                   strcpy(outStr, *((char **) value));
> > +           }
> > +
> > +   } else {
> > +           /* We didn't get the attribute value from IMM. Return error
> (-1) */
> > +           rc = (-1);
> > +   }
> > +   (void) immutil_saImmOmFinalize(omHandle);
> > +
> > +   return rc;
> > +}
> > +
> >   /**
> >    * Return info about which SC node that is Active
> >    *
> > diff --git a/tests/logsv/logtest.h b/tests/logsv/logtest.h
> > --- a/tests/logsv/logtest.h
> > +++ b/tests/logsv/logtest.h
> > @@ -27,6 +27,7 @@
> >   #include <utest.h>
> >   #include <util.h>
> >
> > +#define SA_LOG_CONFIGURATION_OBJECT
> "logConfig=1,safApp=safLogService"
> >   #define SA_LOG_STREAM_APPLICATION1 "safLgStr=saLogApplication1"
> >   #define SA_LOG_STREAM_APPLICATION2 "safLgStr=saLogApplication2"
> >   #define SA_LOG_STREAM_APPLICATION3 "safLgStr=saLogApplication3"
> > @@ -52,6 +53,7 @@ extern SaNameT notificationStreamName;
> >   extern SaNameT app1StreamName;
> >   extern SaNameT notifyingObject;
> >   extern SaNameT notificationObject;
> > +extern SaNameT configurationObject;
> >   extern SaNameT saNameT_Object_256;
> >   extern SaNameT saNameT_appstream_name_256;
> >   extern SaVersionT logVersion;
> > @@ -70,4 +72,6 @@ extern char log_root_path[];
> >   int tet_system(const char *command);
> >
> >   int get_active_sc(void);
> > +int get_attr_value(SaNameT *inObjName, char *inAttr, void **outNum,
> char *outStr);
> > +
> >   #endif
> > diff --git a/tests/logsv/tet_LogOiOps.c b/tests/logsv/tet_LogOiOps.c
> > --- a/tests/logsv/tet_LogOiOps.c
> > +++ b/tests/logsv/tet_LogOiOps.c
> > @@ -1,3 +1,4 @@
> > +
> >   /*      -*- OpenSAF  -*-
> >    *
> >    * (C) Copyright 2008 The OpenSAF Foundation
> > @@ -63,8 +64,8 @@ void saLogOi_01(void)
> >                     fprintf(stderr, "Failed to modify filename back to
> saLogNotification\n");
> >             }
> >     }
> > -
> > -    rc_validate(WEXITSTATUS(rc), 0);
> > +
> > +   rc_validate(WEXITSTATUS(rc), 0);
> >   }
> >
> >   /**
> > @@ -1202,11 +1203,11 @@ void saLogOi_62(void)
> >   {
> >       int rc;
> >       char command[256];
> > -
> > +
> [giang] remove spaces here.
> >       sprintf(command, "immcfg -a logMaxApplicationStreams=%d"
> >                     " logConfig=1,safApp=safLogService 2>
> /dev/null",65);
> >       rc = system(command);
> > -    rc_validate(WEXITSTATUS(rc), 1);
> > +    rc_validate(WEXITSTATUS(rc), 1);
> >   }
> >
> >   /**
> > @@ -2016,6 +2017,458 @@ void saLogOi_115(void)
> >     rc_validate(WEXITSTATUS(rc), 1);
> >   }
> >
> > +/****************************************
> > + * These below functions are used to test added new tokens:
> > + * @Nz/@Cz: Represents a field of 5 characters with format [+-][hhmm]
> > + * The content gives the deviation in hours and minutes btw local
> time/standard time
> > + *
> > + * @Nk/@Ck: Represents time in milliseconds of the seconds from
> logTimeStamp
> > + * Format will be 3 digits.
> > + *
> > + * Each test case will follow the sequences:
> > + *
> > + * 1. Get the current attribute from IMM
> > + * 2. Modify the attribute
> > + * 3. Send a log stream
> > + * 4. Check content of configuration (*.cfg)/log file (*.log)
> > + * 5. Restore the attribute to previous value
> > + *
> > + ***************************************/
> > +
> > +/* Default format expression for alm/not streams */
> > +#define DEFAULT_ALM_NOT_FORMAT_EXP "@Cr @Ct @Nt @Ne6
> @No30 @Ng30 \"@Cb\""
> > +
> > +/* Default format expression for sys/app streams */
> > +#define DEFAULT_APP_SYS_FORMAT_EXP "@Cr @Ch:@Cn:@Cs
> @Cm/@Cd/@CY @Sv @Sl \"@Cb\""
> > +
> > +/* Commands to search for specific pattern on files having 01 last minute
> > + * (?) accessed, but only openning file.
> > + * The flow of execution as below:
> > + *
> > + * 1. Find (linux `find` command) all files in the directory specificed by
> > + * %s (e.g: root_log_path) and subfolders which having 01 last minute
> accessed
> > + * (e.g: read/write access) or lesser.
> > + *
> > + * 2. With `egrep``, it helps to filter just openning log files
> > + * in list of files found - which have correct format
> > + * <logfilename>_<yyyymmdd>_<hhmmss>.log
> > + *
> > + * 3. With `egrep`, search content in the list of right-format
> > + * found files for a specific pattern
> > + * (e.g: timezone format = [+-][0-9]{4}, millisecond format = [0-9]{3})
> > + *
> > + * 4. Don't show found result (if tester wants to see the search result,
> > + * comment final line and its above slash)
> > + *
> > + * Note: If found pattern, exit status of these pipes will be
> > + * EXIT_SUCCESS(0), otherwise EXIT_FAILURE(1)/non-zero(?)
> > + */
> > +#define VERIFY_CMD "find %s -type f -mmin -1" \
> > +                   " | egrep \".*(%s_[0-9]{8}_[0-9]{6})\\.log$\"" \
> > +                   " | xargs egrep  \" %s \"" \
> > +                   " 1> /dev/null"
> > +
> > +/* Search pattern for timezone token format (@Cz/@Nz) */
> > +#define TIMEZ_PATTERN "[+-][0-9]{4}"       /* format: 5 characters with
> format [+-][hhmm] */
> > +/* Search pattern for millisecond token format (@Ck/@Nk) */
> > +#define MILLI_PATTERN "[0-9]{3}"   /* format: 3 digits */
> > +
> > +#define ALM_LOG_FILE "saLogAlarm"
> > +#define NTF_LOG_FILE "saLogNotification"
> > +#define SYS_LOG_FILE "saLogSystem"
> > +#define MAX_DATA 256
> > +
> > +/* immcfg command to modify saLogStreamLogFileFormat for a specific
> DN */
> > +#define IMMCFG_CMD "immcfg -a saLogStreamLogFileFormat=\"%s\"
> %s"
> > +
> > +/**
> > + * CCB Object Modify saLogStreamLogFileFormat of alarm log stream
> > + * by adding timezon token and check if configuration/log file
> > + * are reflected correctly.
> > + */
> > +void modStrLogFileFmt_01(void)
> > +{
> > +    int rc;
> > +    char command[MAX_DATA];
> > +    char preLogStrFileFmt[MAX_DATA];
> > +    /* Enable timezone format - @Nz */
> > +    const char* modLogStrFileFmt = "@Cr @Ct @Nt @Nz @Ne6 @No30
> @Ng30 @Cb";
> > +
> > +    /* Get current value of the attribute, use default value if failed */
> > +    rc = get_attr_value(&alarmStreamName, "saLogStreamLogFileFormat",
> NULL,
> > +                                           preLogStrFileFmt);
> > +    if (rc == -1) {
> > +           /* Failed, use default one */
> > +           fprintf(stderr, "Failed to get attribute value from IMM\n");
> > +           strncpy(preLogStrFileFmt,
> DEFAULT_ALM_NOT_FORMAT_EXP, MAX_DATA);
> > +    }
> > +
> > +    /* Modify the attribute */
> > +    sprintf(command, IMMCFG_CMD, modLogStrFileFmt,
> SA_LOG_STREAM_ALARM);
> > +    rc = system(command);
> > +    if (WEXITSTATUS(rc) == 0) {
> > +           /* Send an alarm to alarm log stream */
> > +           rc = system("saflogger -l");
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to send the alarm to log stream */
> > +                   fprintf(stderr, "Failed to invoke saflogger -a\n");
> > +                   rc_validate(WEXITSTATUS(rc), 0);
> > +                   /* Exit the test case */
> > +                   return;
> > +           }
> > +
> > +           /* Verify the content of log file if it is reflected with right
> format */
> > +           sprintf(command, VERIFY_CMD, log_root_path,
> ALM_LOG_FILE, TIMEZ_PATTERN);
> > +           rc = system(command);
> > +           if (rc == -1) {
> > +                   fprintf(stderr, "Failed to execute command (%s) on
> shell\n",
> > +                                   VERIFY_CMD);
> > +                   test_validate(rc, 0);
> > +                   /* Exit the test case */
> > +                   return;
> > +           }
> > +           /* Command is executed succesfully on the shell, verify the
> result */
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +
> > +           /* Restore the attribute to previous value */
> > +           sprintf(command, IMMCFG_CMD, preLogStrFileFmt,
> SA_LOG_STREAM_ALARM);
> > +           rc = system(command);
> > +           if (WEXITSTATUS(rc) != 0) {
> > +                   /* Failed to restore to privous value, print message
> */
> > +                   fprintf(stderr, "Failed to restore the attribute to
> previous value\n");
> > +           }
> > +    } else {
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +    }
> > +}
> > +
> > +/**
> > + * CCB Object Modify saLogStreamLogFileFormat of alarm log stream
> > + * by adding millisecond token and check if configuration/log file
> > + * are reflected correctly.
> > + */
> > +void modStrLogFileFmt_02(void)
> > +{
> > +    int rc;
> > +    char command[MAX_DATA];
> > +    char preLogStrFileFmt[MAX_DATA];
> > +    /* Enable millisecond format - @Nk */
> > +    const char* modLogStrFileFmt = "@Cr @Ct @Nt @Nk @Ne6 @No30
> @Ng30 @Cb";
> > +
> > +    /* Get current value of the attribute, use default value if failed */
> > +    rc = get_attr_value(&alarmStreamName, "saLogStreamLogFileFormat",
> NULL,
> > +                                           preLogStrFileFmt);
> > +    if (rc == -1) {
> > +           /* Failed, use default one */
> > +           fprintf(stderr, "Failed to get attribute value from IMM\n");
> > +           strncpy(preLogStrFileFmt,
> DEFAULT_ALM_NOT_FORMAT_EXP, MAX_DATA);
> > +    }
> > +
> > +    /* Modify the attribute */
> > +    sprintf(command, IMMCFG_CMD, modLogStrFileFmt,
> SA_LOG_STREAM_ALARM);
> > +    rc = system(command);
> > +    if (WEXITSTATUS(rc) == 0) {
> > +           /* Send an alarm to alarm log stream */
> > +           rc = system("saflogger -l");
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to send the alarm to alarm log stream.
> Report error, then exit */
> > +                   fprintf(stderr, "Failed to invoke saflogger -l\n");
> > +                   rc_validate(WEXITSTATUS(rc), 0);
> > +                   return;
> > +           }
> > +
> > +           /* Verify the content of log file if it is reflected with right
> format */
> > +           sprintf(command, VERIFY_CMD, log_root_path,
> ALM_LOG_FILE, MILLI_PATTERN);
> > +           rc = system(command);
> > +           if (rc == -1) {
> > +                   /* Failed to execute command on shell. Report error,
> then exit */
> > +                   fprintf(stderr, "Failed to execute command (%s) on
> the shell \n",
> > +                                   VERIFY_CMD);
> > +                   test_validate(rc, 0);
> > +                   /* Exit the test case */
> > +                   return;
> > +           }
> > +           /* Command is executed succesfully on the shell. Verify the
> result */
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +
> > +           /* Restore the attribute to previous value */
> > +           sprintf(command, IMMCFG_CMD, preLogStrFileFmt,
> SA_LOG_STREAM_ALARM);
> > +           rc = system(command);
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to restore the attribute to previous value */
> > +                   fprintf(stderr, "Failed to restore the attribute to
> previous value \n");
> > +           }
> > +    } else {
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +    }
> > +}
> > +
> > +/**
> > + * CCB Object Modify saLogStreamLogFileFormat of system log stream
> > + * by adding timezon token and check if configuration/log file
> > + * are reflected correctly.
> > + */
> > +void modStrLogFileFmt_03(void)
> > +{
> > +    int rc;
> > +    char command[MAX_DATA];
> > +    char preLogStrFileFmt[MAX_DATA];
> > +    /* Enable timezone format - @Cz */
> > +    const char* modLogStrFileFmt = "@Cr @Ch:@Cn:@Cs @Cm/@Cd/@CY
> @Cz @Sv @Sl \"@Cb\"";
> > +
> > +    /* Get current value of the attribute, use default value if failed 
> > (-1) */
> > +    rc = get_attr_value(&systemStreamName,
> "saLogStreamLogFileFormat", NULL,
> > +                                           preLogStrFileFmt);
> > +    if (rc == -1) {
> > +           /* Failed, use default one */
> > +           fprintf(stderr, "Failed to get attribute value from IMM\n");
> > +           strncpy(preLogStrFileFmt,
> DEFAULT_APP_SYS_FORMAT_EXP, MAX_DATA);
> > +    }
> > +
> > +    /* Modify the attribute */
> > +    sprintf(command, IMMCFG_CMD, modLogStrFileFmt,
> SA_LOG_STREAM_SYSTEM);
> > +    rc = system(command);
> > +    if (WEXITSTATUS(rc) == 0) {
> > +           /* Send an system log to system log stream */
> > +           rc = system("saflogger -y");
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to send system log to system log stream */
> > +                   fprintf(stderr, "Failed to invoke saflogger -y");
> > +                   rc_validate(WEXITSTATUS(rc), 0);
> > +                   /* Exit the test case */
> > +                   return;
> > +           }
> > +
> > +           /* Verify the content of log file if it is reflected with right
> format */
> > +           sprintf(command, VERIFY_CMD, log_root_path,
> SYS_LOG_FILE, TIMEZ_PATTERN);
> > +           rc = system(command);
> > +           if (rc == -1) {
> > +                   /* Failed to execute command on the shell. Report
> error, then exit */
> > +                   fprintf(stderr, "Failed to execute the command (%s)
> on the shell \n",
> > +                                   VERIFY_CMD);
> > +                   test_validate(rc, 0);
> > +                   /* Exit the test case */
> > +                   return;
> > +           }
> > +           /* The command executed succesfully on the shell. Verify
> the result */
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +
> > +           /* Restore the attribute to previous value */
> > +           sprintf(command, IMMCFG_CMD, preLogStrFileFmt,
> SA_LOG_STREAM_SYSTEM);
> > +           rc = system(command);
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to restore the attribute to previous value */
> > +                   fprintf(stderr, "Failed to restore the attribute to
> previous value \n");
> > +           }
> > +
> > +    } else {
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +    }
> > +}
> > +
> > +/**
> > + * CCB Object Modify saLogStreamLogFileFormat of system log stream
> > + * by adding millisecond token and check if configuration/log file
> > + * are reflected correctly.
> > + */
> > +void modStrLogFileFmt_04(void)
> > +{
> > +    int rc;
> > +    char command[MAX_DATA];
> > +    char preLogStrFileFmt[MAX_DATA];
> > +    /* Enable timezone format - @Ck */
> > +    const char* modLogStrFileFmt = "@Cr @Ch:@Cn:@Cs @Cm/@Cd/@CY
> @Ck @Sv @Sl @Cb";
> > +
> > +    /* Get current value of the attribute, use default value if failed 
> > (-1) */
> > +    rc = get_attr_value(&systemStreamName,
> "saLogStreamLogFileFormat", NULL,
> > +                                           preLogStrFileFmt);
> > +    if (rc == -1) {
> > +           /* Failed, use default one */
> > +           fprintf(stderr, "Failed to get attribute value from IMM\n");
> > +           strncpy(preLogStrFileFmt,
> DEFAULT_APP_SYS_FORMAT_EXP, MAX_DATA);
> > +    }
> > +
> > +    /* Modify the attribute */
> > +    sprintf(command, IMMCFG_CMD, modLogStrFileFmt,
> SA_LOG_STREAM_SYSTEM);
> > +    rc = system(command);
> > +    if (WEXITSTATUS(rc) == 0) {
> > +           /* Send an system log to system log stream */
> > +           rc = system("saflogger -y");
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to send system log to system log stream */
> > +                   fprintf(stderr, "Failed to invoke saflogger -y\n");
> > +                   rc_validate(WEXITSTATUS(rc), 0);
> > +                   return;
> > +           }
> > +
> > +           /* Verify the content of log file if it is reflected with right
> format */
> > +           sprintf(command, VERIFY_CMD, log_root_path,
> SYS_LOG_FILE, MILLI_PATTERN);
> > +           rc = system(command);
> > +           if (rc == -1) {
> > +                   /* Failed to execute the command on the shell.
> Report error, then exit. */
> > +                   fprintf(stderr, "Failed to execute command (%s) on
> the shell. \n",
> > +                                   VERIFY_CMD);
> > +                   test_validate(rc, 0);
> > +                   /* Exit the test case */
> > +                   return;
> > +           }
> > +
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +
> > +           /* Restore the attribute to previous value */
> > +           sprintf(command, IMMCFG_CMD, preLogStrFileFmt,
> SA_LOG_STREAM_SYSTEM);
> > +           rc = system(command);
> > +           if (WEXITSTATUS(rc)) {
> > +                   fprintf(stderr, "Failed to restore the attribute to
> previous value \n");
> > +           }
> > +    } else {
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +    }
> > +}
> > +
> > +/**
> > + * CCB Object Modify saLogStreamLogFileFormat of system log stream
> > + * by adding timezone and millisecond token
> > + * then check if configuration/log file are reflected correctly.
> > + */
> > +void modStrLogFileFmt_05(void)
> > +{
> > +    int rc;
> > +    char command[MAX_DATA];
> > +    char preLogStrFileFmt[MAX_DATA];
> > +    /* Enable timezone and millisecond token - @Cz @Ck */
> > +    const char* modLogStrFileFmt = "@Cr @Ch:@Cn:@Cs @Cm/@Cd/@CY
> @Cz @Ck @Sv @Sl @Cb";
> > +
> > +    /* Get current value of the attribute, use default value if failed 
> > (-1) */
> > +    rc = get_attr_value(&systemStreamName,
> "saLogStreamLogFileFormat", NULL,
> > +                                           preLogStrFileFmt);
> > +    if (rc == -1) {
> > +           /* Failed, use default one */
> > +           fprintf(stderr, "Failed to get attribute value from IMM\n");
> > +           strncpy(preLogStrFileFmt,
> DEFAULT_APP_SYS_FORMAT_EXP, MAX_DATA);
> > +    }
> > +
> > +    /* Modify the attribute */
> > +    sprintf(command, IMMCFG_CMD, modLogStrFileFmt,
> SA_LOG_STREAM_SYSTEM);
> > +    rc = system(command);
> > +    if (WEXITSTATUS(rc) == 0) {
> > +           /* Send an system log to system log stream */
> > +           rc = system("saflogger -y");
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to send system log to sys log stream */
> > +                   fprintf(stderr, "Failed to invoke saflogger -y\n");
> > +                   rc_validate(WEXITSTATUS(rc), 0);
> > +                   return;
> > +           }
> > +
> > +           char tZoneMillP[MAX_DATA];
> > +           sprintf(tZoneMillP, "%s %s", TIMEZ_PATTERN,
> MILLI_PATTERN);
> > +
> > +           /* Verify the content of log file if it is reflected with right
> format */
> > +           sprintf(command, VERIFY_CMD, log_root_path,
> SYS_LOG_FILE, tZoneMillP);
> > +           rc = system(command);
> > +           if (rc == -1) {
> > +                   /* Failed to execute command on the shell. Report
> error, then exit */
> > +                   fprintf(stderr, "Failed to execute command (%s) on
> the shell. \n",
> > +                                   VERIFY_CMD);
> > +                   test_validate(rc, 0);
> > +                   return;
> > +           }
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +
> > +           /* Restore the attribute to previous value */
> > +           sprintf(command, IMMCFG_CMD, preLogStrFileFmt,
> SA_LOG_STREAM_SYSTEM);
> > +           rc = system(command);
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to restore the attribute to previous value */
> > +                   fprintf(stderr, "Failed to restore to previous value
> \n");
> > +           }
> > +    } else {
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +    }
> > +}
> > +
> > +/**
> > + * Change logStreamFileFormat attribute, then create application stream
> > + * with logFileFmt set to NULL. Write a log record to that stream.
> > + *
> > + * Check whether written log file format is reflected correctly
> > + * with one defined by logStreamFileFormat.
> > + *
> > + */
> > +void verDefaultLogFileFmt(void)
> > +{
> > +    int rc;
> > +    char command[MAX_DATA];
> > +    char preLogStrFileFmt[MAX_DATA];
> > +   char appLogPath[MAX_DATA];
> > +
> > +    /* Enable timezone and millisecond token - @Cz @Ck */
> > +    const char* modLogStrFileFmt = "@Cr @Ch:@Cn:@Cs @Cm/@Cd/@CY
> @Cz @Ck @Sv @Sl @Cb";
> > +   /*
> > +     The description for this macro is same as one for VERIFY_CMD.
> > +     Except, it includes close timestamp.
> > +    */
> > +#define VERIFY_CMD_ "find %s -type f -mmin -1" \
> > +           " | egrep \"%s_[0-9]{8}_[0-9]{6}_[0-9]{8}_[0-9]{6}\\.log$\"" \
> > +           " | xargs egrep  \" %s \"" \
> > +           " 1> /dev/null"
> > +
> > +    /* Get current value of the attribute, use default value if failed 
> > (-1) */
> > +   rc = get_attr_value(&configurationObject, "logStreamFileFormat",
> NULL,
> > +                                           preLogStrFileFmt);
> > +    if (rc == -1) {
> > +           /* Failed, use default one */
> > +           strncpy(preLogStrFileFmt,
> DEFAULT_APP_SYS_FORMAT_EXP, MAX_DATA);
> > +    }
> > +
> > +    /* Modify the attribute */
> > +    sprintf(command, "immcfg -a logStreamFileFormat=\"%s\" %s",
> > +                   modLogStrFileFmt,
> SA_LOG_CONFIGURATION_OBJECT);
> > +
> > +    rc = system(command);
> > +    if (WEXITSTATUS(rc) == 0) {
> > +           /* Send an system log to app stream */
> > +           rc = system("saflogger -a
> safLgStrCfg=verDefaultLogFileFmt");
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to send log record to app stream */
> > +                   fprintf(stderr, "Failed to invoke saflogger -a\n");
> > +                   rc_validate(WEXITSTATUS(rc), 0);
> > +                   return;
> > +           }
> > +
> > +           char tZoneMillP[MAX_DATA];
> > +           sprintf(tZoneMillP, "%s %s", TIMEZ_PATTERN,
> MILLI_PATTERN);
> > +
> > +           /* Verify the content of log file if it is reflected with right
> format */
> > +           sprintf(appLogPath, "%s/saflogger", log_root_path);
> > +           sprintf(command, VERIFY_CMD_, appLogPath,
> > +                           "safLgStrCfg=verDefaultLogFileFmt",
>       tZoneMillP);
> > +
> > +           rc = system(command);
> > +           if (rc == -1) {
> > +                   /* Failed to execute command on the shell. Report
> error, then exit */
> > +                   fprintf(stderr, "Failed to execute command (%s) on
> the shell. \n",
> > +                                   VERIFY_CMD_);
> > +                   test_validate(rc, 0);
> > +                   return;
> > +           }
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +
> > +           /* Restore the attribute to previous value */
> > +           sprintf(command, "immcfg -a logStreamFileFormat=\"%s\"
> %s",
> > +                           preLogStrFileFmt,
> SA_LOG_CONFIGURATION_OBJECT);
> > +
> > +           rc = system(command);
> > +           if (WEXITSTATUS(rc)) {
> > +                   /* Failed to restore the attribute to previous value */
> > +                   fprintf(stderr, "Failed to restore to previous value
> \n");
> > +           }
> > +    } else {
> > +           rc_validate(WEXITSTATUS(rc), 0);
> > +    }
> > +}
> > +
> >   #undef MAX_LOGRECSIZE
> >
> >   __attribute__ ((constructor)) static void
> saOiOperations_constructor(void)
> > @@ -2079,7 +2532,13 @@ void saLogOi_115(void)
> >       test_case_add(4, saLogOi_40, "CCB Object Delete, strA");
> >       test_case_add(4, saLogOi_50, "saflogtest, writing to appTest");
> >       test_case_add(4, saLogOi_51, "saflogtest, writing to 
> > saLogApplication1,
> severity filtering check");
> > -
> > +    test_case_add(4, modStrLogFileFmt_01, "CCB Object Modify,
> saLogstreamLogFileFormat, timezone token (@Nz)");
> > +    test_case_add(4, modStrLogFileFmt_02, "CCB Object Modify,
> saLogstreamLogFileFormat, millisecond token (@Nk)");
> > +    test_case_add(4, modStrLogFileFmt_03, "CCB Object Modify,
> saLogstreamLogFileFormat, timezone token (@Cz)");
> > +    test_case_add(4, modStrLogFileFmt_04, "CCB Object Modify,
> saLogstreamLogFileFormat, millisecond token (@Ck)");
> > +    test_case_add(4, modStrLogFileFmt_05, "CCB Object Modify,
> saLogstreamLogFileFormat, timezone & millisecond token (@Cz @Ck)");
> > +    test_case_add(4, verDefaultLogFileFmt, "Application stream with
> default log file format");
> > +
> >     /* Configuration object */
> >       test_suite_add(5, "LOG OI tests, Service configuration object");
> >       test_case_add(5, saLogOi_52, "CCB Object Modify, root directory. Path
> does not exist. Not allowed");
> >

------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to