From: <mat...@or...> - 2014-05-22 14:32:48
|
Summary: log: handle ending quote for messages in variable log records: v2 [#882] Review request for Trac Ticket(s): <<IF ANY LIST THE #>> Peer Reviewer(s): Lennart Pull request to: <<LIST THE PERSON WITH PUSH ACCESS HERE>> Affected branch(es): 4.3.x, 4.4.x, default Development branch: <<IF ANY GIVE THE REPO URL>> -------------------------------- Impacted area Impact y/n -------------------------------- Docs n Build system n RPM/packaging n Configuration files n Startup scripts n SAF services y OpenSAF services n Core libraries n Samples n Tests n Other n Comments (indicate scope for each "y" above): --------------------------------------------- changeset b004b7447aa2e17a3c3cca21ccf1fe21d8bc2f0d Author: Mathivanan N.P.<mat...@or...> Date: Thu, 22 May 2014 19:50:25 -0400 log: handle ending quote for messages in variable log records [#882] 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. Complete diffstat: ------------------ 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(-) Testing Commands: ----------------- The following commands should print with both open and closing quotes and subsequent log records should end up in a new line: Suite1: Test case1: $saflogger -y Result: Should create an empty string with open and close quotes in the system stream. Testcase2: saflogger -y hello Result: Should create the string "hello" from a new line in the system stream. Testcase3: saflogger -y "a big string... bigger than 1024" Result: Should create the string "a big string... bigger than 1024" from a new line inthe system stream. Repeat 1, 2, 3 above in different order. Suite2: Run the above commands for application stream. Testcase3 should print only 128 byte long strings withinquotes in teh application stream. For eg:- $saflogger -a dumper For eg:- $saflogger -a dumper hello For eg:- $saflogger -a dumper "string bigger than 128 bytes" Suite3: Modify saflogger to enable variable length records: Repeat tests under Suite1 Suite4: Modify saflogger to enable variable length records: Repeat tests under Suite2 For Testcase3, should print only 1024 byte strings because default max filesize for app streams is 1024. Testing, Expected Results: -------------------------- Same as Above. Conditions of Submission: ------------------------- Ack from Lennart. Arch Built Started Linux distro ------------------------------------------- mips n n mips64 n n x86 n n x86_64 n n powerpc n n powerpc64 n n Reviewer Checklist: ------------------- [Submitters: make sure that your review doesn't trigger any checkmarks!] Your checkin has not passed review because (see checked entries): ___ Your RR template is generally incomplete; it has too many blank entries that need proper data filled in. ___ You have failed to nominate the proper persons for review and push. ___ Your patches do not have proper short+long header ___ You have grammar/spelling in your header that is unacceptable. ___ You have exceeded a sensible line length in your headers/comments/text. ___ You have failed to put in a proper Trac Ticket # into your commits. ___ You have incorrectly put/left internal data in your comments/files (i.e. internal bug tracking tool IDs, product names etc) ___ You have not given any evidence of testing beyond basic build tests. Demonstrate some level of runtime or other sanity testing. ___ You have ^M present in some of your files. These have to be removed. ___ You have needlessly changed whitespace or added whitespace crimes like trailing spaces, or spaces before tabs. ___ You have mixed real technical changes with whitespace and other cosmetic code cleanup changes. These have to be separate commits. ___ You need to refactor your submission into logical chunks; there is too much content into a single commit. ___ You have extraneous garbage in your review (merge commits etc) ___ You have giant attachments which should never have been sent; Instead you should place your content in a public tree to be pulled. ___ You have too many commits attached to an e-mail; resend as threaded commits, or place in a public tree for a pull. ___ You have resent this content multiple times without a clear indication of what has changed between each re-send. ___ You have failed to adequately and individually address all of the comments and change requests that were proposed in the initial review. ___ You have a misconfigured ~/.hgrc file (i.e. username, email etc) ___ Your computer have a badly configured date and time; confusing the the threaded patch review. ___ Your changes affect IPC mechanism, and you don't present any results for in-service upgradability test. ___ Your changes affect user manual and documentation, your patch series do not contain the patch that updates the Doxygen manual. |
From: <mat...@or...> - 2014-05-22 14:32:55
|
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__); |
From: Lennart L. <len...@er...> - 2014-05-23 07:39:50
|
Hi, Ack Have tested. Looks good Thanks Lennart > -----Original Message----- > From: mat...@or... [mailto:mat...@or...] > Sent: den 23 maj 2014 02:02 > To: Lennart Lund > Cc: ope...@li... > Subject: [PATCH 0 of 1] Review Request for log: handle ending quote for > messages in variable log records: v2 [#882] > > Summary: log: handle ending quote for messages in variable log records: v2 > [#882] Review request for Trac Ticket(s): <<IF ANY LIST THE #>> Peer > Reviewer(s): Lennart Pull request to: <<LIST THE PERSON WITH PUSH ACCESS > HERE>> Affected branch(es): 4.3.x, 4.4.x, default Development branch: <<IF > ANY GIVE THE REPO URL>> > > -------------------------------- > Impacted area Impact y/n > -------------------------------- > Docs n > Build system n > RPM/packaging n > Configuration files n > Startup scripts n > SAF services y > OpenSAF services n > Core libraries n > Samples n > Tests n > Other n > > > Comments (indicate scope for each "y" above): > --------------------------------------------- > > changeset b004b7447aa2e17a3c3cca21ccf1fe21d8bc2f0d > Author: Mathivanan N.P.<mat...@or...> > Date: Thu, 22 May 2014 19:50:25 -0400 > > log: handle ending quote for messages in variable log records [#882] > 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. > > > Complete diffstat: > ------------------ > 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(-) > > > Testing Commands: > ----------------- > The following commands should print with both open and closing quotes and > subsequent log records should end up in a new line: > > Suite1: > Test case1: $saflogger -y > Result: Should create an empty string with open and close quotes in the > system stream. > > Testcase2: saflogger -y hello > Result: Should create the string "hello" from a new line in the system stream. > > Testcase3: saflogger -y "a big string... bigger than 1024" > Result: Should create the string "a big string... bigger than 1024" from a new > line inthe system stream. > Repeat 1, 2, 3 above in different order. > > Suite2: > Run the above commands for application stream. > Testcase3 should print only 128 byte long strings withinquotes in teh > application stream. > For eg:- $saflogger -a dumper > For eg:- $saflogger -a dumper hello > For eg:- $saflogger -a dumper "string bigger than 128 bytes" > > Suite3: > Modify saflogger to enable variable length records: > Repeat tests under Suite1 > > Suite4: > Modify saflogger to enable variable length records: > Repeat tests under Suite2 > For Testcase3, should print only 1024 byte strings because default max > filesize for app streams is 1024. > > Testing, Expected Results: > -------------------------- > Same as Above. > > Conditions of Submission: > ------------------------- > Ack from Lennart. > > Arch Built Started Linux distro > ------------------------------------------- > mips n n > mips64 n n > x86 n n > x86_64 n n > powerpc n n > powerpc64 n n > > > Reviewer Checklist: > ------------------- > [Submitters: make sure that your review doesn't trigger any checkmarks!] > > > Your checkin has not passed review because (see checked entries): > > ___ Your RR template is generally incomplete; it has too many blank entries > that need proper data filled in. > > ___ You have failed to nominate the proper persons for review and push. > > ___ Your patches do not have proper short+long header > > ___ You have grammar/spelling in your header that is unacceptable. > > ___ You have exceeded a sensible line length in your > headers/comments/text. > > ___ You have failed to put in a proper Trac Ticket # into your commits. > > ___ You have incorrectly put/left internal data in your comments/files > (i.e. internal bug tracking tool IDs, product names etc) > > ___ You have not given any evidence of testing beyond basic build tests. > Demonstrate some level of runtime or other sanity testing. > > ___ You have ^M present in some of your files. These have to be removed. > > ___ You have needlessly changed whitespace or added whitespace crimes > like trailing spaces, or spaces before tabs. > > ___ You have mixed real technical changes with whitespace and other > cosmetic code cleanup changes. These have to be separate commits. > > ___ You need to refactor your submission into logical chunks; there is > too much content into a single commit. > > ___ You have extraneous garbage in your review (merge commits etc) > > ___ You have giant attachments which should never have been sent; > Instead you should place your content in a public tree to be pulled. > > ___ You have too many commits attached to an e-mail; resend as threaded > commits, or place in a public tree for a pull. > > ___ You have resent this content multiple times without a clear indication > of what has changed between each re-send. > > ___ You have failed to adequately and individually address all of the > comments and change requests that were proposed in the initial review. > > ___ You have a misconfigured ~/.hgrc file (i.e. username, email etc) > > ___ Your computer have a badly configured date and time; confusing the > the threaded patch review. > > ___ Your changes affect IPC mechanism, and you don't present any results > for in-service upgradability test. > > ___ Your changes affect user manual and documentation, your patch series > do not contain the patch that updates the Doxygen manual. |