osaf/services/saf/logsv/lgs/lgs_evt.c   |   2 +-
 osaf/services/saf/logsv/lgs/lgs_fmt.c   |  26 +++++++++++++++++++++++---
 osaf/services/saf/logsv/lgs/lgs_fmt.h   |   2 +-
 osaf/services/saf/logsv/lgs/lgs_mbcsv.c |   2 +-
 4 files changed, 26 insertions(+), 6 deletions(-)


Currently, When varible log records are enabled for applications, the log
message is missing the ending quote. i.e. as below
saflogger -a test will create a message with a single open quote:
saflogger -a test hello will create the message witha single openquote : hello
The same behaviour can be seen for system streams also.
The problem is that when the logoutputstring
is constructed, the ending quotes are indeed getting added to the output
string, but this is getting overwritten by the existing code when
introducing the newline character tothe logoutputstring. The patch inserts the
newline to the outputstring after the ending quote and also adjusts
the length of the final logstring to be printed.

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
@@ -1150,7 +1150,7 @@ static uint32_t proc_write_log_async_msg
                goto done;
        }
 
-       if ((n = lgs_format_log_record(param->logRecord, stream->logFileFormat,
+       if ((n = lgs_format_log_record(param->logRecord, stream->logFileFormat, 
stream->maxLogFileSize,
                stream->fixedLogRecordSize, buf_size, logOutputString, 
++stream->logRecordId)) == 0) {
                error = SA_AIS_ERR_INVALID_PARAM;
                goto done;
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
@@ -1152,7 +1152,7 @@ SaBoolT lgs_is_valid_format_expression(c
  * 
  * @return int number of bytes written to dest
  */
-int lgs_format_log_record(SaLogRecordT *logRecord, const SaStringT 
formatExpression,
+int lgs_format_log_record(SaLogRecordT *logRecord, const SaStringT 
formatExpression, SaUint64T logFileSize,
        SaUint16T fixedLogRecordSize, size_t dest_size, char *dest, SaUint32T 
logRecordIdCounter)
 {
        SaStringT fmtExpPtr = &formatExpression[0];
@@ -1247,8 +1247,28 @@ int lgs_format_log_record(SaLogRecordT *
                memset(&dest[i], ' ', fixedLogRecordSize - i);
                dest[fixedLogRecordSize - 1] = '\n';
                i = fixedLogRecordSize;
-       } else {
-               dest[i - 1] = '\n';
+       } else if ((fixedLogRecordSize > 0) && (i >= fixedLogRecordSize)) {
+               dest[fixedLogRecordSize - 2] = (SaInt8T)'\"';
+               dest[fixedLogRecordSize - 1] = '\n';
+               i = fixedLogRecordSize;
+       }
+
+       if ((fixedLogRecordSize == 0) && (i < dest_size)) {
+               dest[i] = '\n';
+               ++i;
+       } else if ((fixedLogRecordSize == 0) && (i >= dest_size)) { /* dest 
size = record size +1 */
+               if (i >= logFileSize) {
+               /* There can be situations when the filesize is as small as the 
maxrecsize.
+                * For eg:- By default for the application streams max file 
size is 1024 
+                */
+                       dest[logFileSize - 2] = (SaInt8T)'\"';
+                       dest[logFileSize - 1] = '\n';
+                       i = logFileSize;
+               } else {
+                       dest[dest_size - 2] = (SaInt8T)'\"';
+                       dest[dest_size - 1] = '\n';
+                       i = dest_size;
+               }
        }
 
        if (truncationLetterPos != -1) {        /* Insert truncation info 
letter */
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
@@ -164,7 +164,7 @@ typedef enum {
 } logStreamTypeT;
 
 extern SaBoolT lgs_is_valid_format_expression(const SaStringT, logStreamTypeT, 
SaBoolT *);
-extern int lgs_format_log_record(SaLogRecordT *, const SaStringT, SaUint16T 
fixedLogRecordSize,
+extern int lgs_format_log_record(SaLogRecordT *, const SaStringT, SaUint64T 
logFileSize, SaUint16T fixedLogRecordSize,
        size_t dest_size, char *dest, SaUint32T);
 
 #endif
diff --git a/osaf/services/saf/logsv/lgs/lgs_mbcsv.c 
b/osaf/services/saf/logsv/lgs/lgs_mbcsv.c
--- a/osaf/services/saf/logsv/lgs/lgs_mbcsv.c
+++ b/osaf/services/saf/logsv/lgs/lgs_mbcsv.c
@@ -1489,7 +1489,7 @@ static void insert_localmsg_in_stream(lo
        }
 
        /* Format the log record */
-       if ((n = lgs_format_log_record(&log_record, stream->logFileFormat,
+       if ((n = lgs_format_log_record(&log_record, stream->logFileFormat, 
stream->maxLogFileSize,
                        stream->fixedLogRecordSize, buf_size, logOutputString,
                        LOG_REC_ID)) == 0) {
                LOG_ER("%s - Could not format internal log 
record",__FUNCTION__);

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to