opensaf  5.21.09
About: OpenSAF is a project focused on Service Availability (SA) that develops middleware based on open and industry standard interfaces for applications requiring uninterrupted 24x7 service.
  Fossies Dox: opensaf-5.21.09.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

saflogtest.c
Go to the documentation of this file.
1
2/* -*- OpenSAF -*-
3 *
4 * (C) Copyright 2011 The OpenSAF Foundation
5 * Copyright Ericsson AB 2011, 2017 - All Rights Reserved.
6 *
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
10 * under the GNU Lesser General Public License Version 2.1, February 1999.
11 * The complete license can be accessed from the following location:
12 * http://opensource.org/licenses/lgpl-license.php
13 * See the Copying file included with the OpenSAF distribution for full
14 * licensing terms.
15 *
16 * Author(s): Ericsson AB
17 *
18 */
19
20/*
21 * This file contains a command line test utility to write to the SAF LOG.
22 *
23 * The main purpose of the utility is to send a burst of log messages, by
24 * default waiting for ack for each message.
25 */
26
27#include <stdio.h>
28#include <stdlib.h>
29#include <stdbool.h>
30#include <string.h>
31#include <errno.h>
32#include <unistd.h>
33#include <getopt.h>
34#include <sys/types.h>
35#include <sys/socket.h>
36#include <sys/select.h>
37#include <sys/un.h>
38#include <sys/time.h>
39#include <fcntl.h>
40#include <ctype.h>
41#include <time.h>
42#include <poll.h>
43#include <unistd.h>
44#include <limits.h>
45#include "base/osaf_time.h"
46#include "base/saf_error.h"
47
48#include <saAis.h>
49#include <saLog.h>
50
51#define DEFAULT_FORMAT_EXPRESSION "@Cr @Ch:@Cn:@Cs @Cm/@Cd/@CY @Sv @Sl \"@Cb\""
52#define DEFAULT_APP_LOG_REC_SIZE 150
53#define DEFAULT_APP_LOG_FILE_SIZE 1024 * 1024
54#define VENDOR_ID 193
55#define DEFAULT_MAX_FILES_ROTATED 4
56
57#define MAX_NUM_STREAM 4
58
59const uint64_t kWaitTime = 10*1000; // Wait for timeout is 10 seconds
60const SaVersionT kLogVersion = {'A', 0x02, 0x03};
61
63
65
66static char *progname = "saflogtest";
69
71{
72 struct timeval tv;
73 SaTimeT ntfTime;
74
75 gettimeofday(&tv, 0);
76
77 ntfTime = ((unsigned)tv.tv_sec * 1000000000ULL) +
78 ((unsigned)tv.tv_usec * 1000ULL);
79
80 return ntfTime;
81}
82
83/**
84 *
85 */
86static void usage(void)
87{
88 printf("\nNAME\n");
89 printf("\t%s - write log record(s) to log stream\n", progname);
90
91 printf("\nSYNOPSIS\n");
92 printf("\t%s [options] [message ...]\n", progname);
93
94 printf("\nDESCRIPTION\n");
95 printf(
96 "\t%s is a SAF LOG client used to write a log record into a specified log stream.\n",
97 progname);
98
99 printf("\nOPTIONS\n");
100
101 printf(" -h or --help this help\n");
102 printf(
103 " -k or --ack do not wait for ack after write, default wait\n");
104 printf(" -l or --alarm write to alarm stream\n");
105 printf(
106 " -n or --notification write to notification stream\n");
107 printf(
108 " -y or --system write to system stream (default)\n");
109 printf(
110 "%s%s%s",
111 " -a NAME or --application=NAME write to application stream NAME\n",
112 " Can be used more than once, more than one stream can be opened\n",
113 " Cannot be used in combination with other streams\n");
114 printf(" Max %d application streams can be created\n",
116 printf(
117 " Example: > saflogtest -a tst1 \"tst1 msg\" -a tst2 -a tst3 \"tst3 msg\"\n");
118 printf(
119 " -b NAME or --capplication=NAME write to config application stream NAME\n");
120 printf(
121 " -s SEV or --severity=SEV use severity SEV, default INFO\n");
122 printf(
123 " valid severity names: emerg, alert, crit, error, warn, notice, info\n");
124 printf(
125 " -i INT or --interval=INT write with interval INT us (only with --count, default 0us)\n");
126 printf(
127 " -c CNT or --count=CNT write CNT number of times, -1 forever (with interval INT) \n");
128 printf(" -o Open log stream(s) and wait forever. Exit on any key\n");
129 printf(
130 " -e Exit without closing stream(s) or finalizing after log records are written\n");
131}
132
134{
136 cb_error = error;
137}
138
139/**
140 * Write log record to stream, wait for ack
141 * @param logRecord
142 * @param interval
143 * @param write_count
144 *
145 * @return SaAisErrorT
146 */
150 const SaLogRecordT *logRecord,
151 bool wait_for_ack)
152{
153 SaAisErrorT errorCode;
154 SaInvocationT invocation = random();
155 struct pollfd fds[1];
156 int ret;
157 static int i = 0;
158 int try_agains = 0;
159 SaLogAckFlagsT ackflags;
160 struct timespec timeout_time;
161
162 if (wait_for_ack)
163 ackflags = SA_LOG_RECORD_WRITE_ACK;
164 else
165 ackflags = 0;
166retry:
167 osaf_set_millis_timeout(kWaitTime, &timeout_time);
168 while (!osaf_is_timeout(&timeout_time)) {
169
171 ackflags, logRecord);
172 if (errorCode != SA_AIS_ERR_TRY_AGAIN) break;
174 }
175
176 if (errorCode != SA_AIS_OK) {
177 fprintf(stderr, "saLogWriteLogAsync FAILED: %s\n",
178 saf_error(errorCode));
179 return errorCode;
180 }
181
182 if (wait_for_ack) {
183 fds[0].fd = (int)selectionObject;
184 fds[0].events = POLLIN;
185 ackflags = SA_LOG_RECORD_WRITE_ACK;
186
187 poll_retry:
188 ret = poll(fds, 1, 20000);
189
190 if (ret == EINTR)
191 goto poll_retry;
192
193 if (ret == -1) {
194 fprintf(stderr, "poll FAILED: %u\n", ret);
196 }
197
198 if (ret == 0) {
199 fprintf(
200 stderr,
201 "poll timeout, message %u was most likely lost\n",
202 i++);
204 }
205
207 if (errorCode != SA_AIS_OK) {
208 fprintf(stderr, "saLogDispatch FAILED: %s\n",
209 saf_error(errorCode));
210 return errorCode;
211 }
212
213 if (cb_invocation != invocation) {
214 fprintf(stderr, "logWriteLogCallbackT FAILED:"
215 " wrong invocation\n");
217 }
218
220 (cb_error != SA_AIS_OK)) {
221 fprintf(stderr, "logWriteLogCallbackT FAILED: %s\n",
223 return cb_error;
224 }
225
227 !osaf_is_timeout(&timeout_time)) {
229 try_agains++;
230 goto retry;
231 }
232
233 if (try_agains > 0) {
234 fprintf(stderr, "\tgot %u SA_AIS_ERR_TRY_AGAIN\n",
235 try_agains);
236 }
237 }
238
239 return errorCode;
240}
241
243{
244 if (strcmp(severity, "emerg") == 0)
246
247 if (strcmp(severity, "alert") == 0)
248 return SA_LOG_SEV_ALERT;
249
250 if (strcmp(severity, "crit") == 0)
251 return SA_LOG_SEV_CRITICAL;
252
253 if (strcmp(severity, "error") == 0)
254 return SA_LOG_SEV_ERROR;
255
256 if (strcmp(severity, "warn") == 0)
257 return SA_LOG_SEV_WARNING;
258
259 if (strcmp(severity, "notice") == 0)
260 return SA_LOG_SEV_NOTICE;
261
262 if (strcmp(severity, "info") == 0)
263 return SA_LOG_SEV_INFO;
264
265 usage();
266 exit(EXIT_FAILURE);
267}
268
269/**
270 * Creates a log record by filling in the log service API struct of
271 * type SaLogRecordT.
272 * Note: When the log record is written it has to be freed.
273 * Use free_log_record() function
274 *
275 * @param logRecord[out]
276 * @param logHdrType[in]
277 * @param logSvcUsrName[in]
278 * @param notificationClassId[in]
279 * Can be set to NULL if Hdr-type is SA_LOG_GENERIC_HEADER
280 * @param log_message[in]
281 * Set to NULL if there is no message
282 */
283static void create_log_record(SaLogRecordT *logRecord,
284 SaLogHeaderTypeT logHdrType,
286 SaNtfClassIdT *notificationClassId,
287 char *log_message, SaLogBufferT *logBuffer)
288{
289 logRecord->logTimeStamp =
290 SA_TIME_UNKNOWN; /* LOG service should supply timestamp */
291 logRecord->logBuffer = NULL;
292
293 if (logHdrType == SA_LOG_GENERIC_HEADER) {
294 /* Setup generic header */
296 logRecord->logHeader.genericHdr.notificationClassId = NULL;
299 } else if (logHdrType == SA_LOG_NTF_HEADER) {
300 /* Setup header for Alarm and Notification record */
301 logRecord->logHdrType = SA_LOG_NTF_HEADER;
302 logRecord->logHeader.ntfHdr.notificationId =
308 notificationClassId;
310 } else {
311 printf("\nInternal error when setting up log header\n");
312 exit(EXIT_FAILURE);
313 }
314
315 /* Create body of log record (if any) */
316
317 if (log_message != NULL) {
318 int sz = strlen(log_message) + 1;
319 char *logBuf = malloc(
320 sz + 64); /* add space for index/id in periodic writes */
321 strcpy(logBuf, log_message);
322 logBuffer->logBufSize = sz;
323 logBuffer->logBuf = (SaUint8T *)logBuf;
324 logRecord->logBuffer = logBuffer;
325 } else {
326 logRecord->logBuffer = NULL;
327 }
328}
329
330static void free_loc_record(SaLogRecordT *logRecord)
331{
332 if (logRecord->logBuffer != NULL) {
333 free(logRecord->logBuffer->logBuf);
334 }
335}
336
338 SaLogFileCreateAttributesT_2 *logFileCreateAttributes,
339 SaStringT logFileName)
340{
341 /* Setup default values used when creating an application stream using
342 * API */
343 logFileCreateAttributes->logFilePathName = "saflogtest";
344 logFileCreateAttributes->maxLogFileSize = DEFAULT_APP_LOG_FILE_SIZE;
345 logFileCreateAttributes->maxLogRecordSize = DEFAULT_APP_LOG_REC_SIZE;
346 logFileCreateAttributes->haProperty = SA_TRUE;
347 logFileCreateAttributes->logFileFullAction =
349 logFileCreateAttributes->maxFilesRotated = DEFAULT_MAX_FILES_ROTATED;
350 logFileCreateAttributes->logFileFmt = DEFAULT_FORMAT_EXPRESSION;
351 logFileCreateAttributes->logFileName = strdup(logFileName);
352}
353
355 SaLogFileCreateAttributesT_2 *logFileCreateAttributes)
356{
357 if (logFileCreateAttributes != NULL) {
358 free(logFileCreateAttributes->logFileName);
359 }
360}
361
362int main(int argc, char *argv[])
363{
364 int i;
365 // SaNameT logStreamName;
366 SaLogStreamOpenFlagsT logStreamOpenFlags = 0;
368 SaNtfClassIdT notificationClassId = {1, 2, 3};
369 struct option long_options[] = {
370 {"ack", no_argument, 0, 'k'},
371 {"application", required_argument, 0, 'a'},
372 {"capplication", required_argument, 0, 'b'},
373 {"alarm", no_argument, 0, 'l'},
374 {"notification", no_argument, 0, 'n'},
375 {"system", no_argument, 0, 'y'},
376 {"severity", required_argument, 0, 's'},
377 {"interval", required_argument, 0, 'i'},
378 {"count", required_argument, 0, 'c'},
379 {"help", no_argument, 0, 'h'},
380 {0, 0, 0, 0}};
381 int interval = 0;
382 char hostname[_POSIX_HOST_NAME_MAX];
383 int write_count = 1;
384 SaAisErrorT error;
388 bool wait_for_ack = true;
389 bool do_not_exit_f = false;
390 bool no_finalize_exit = false;
391 char *log_message;
392 SaLogSeverityT logSeverity = SA_LOG_SEV_INFO;
393
394 int stream_cnt = 0;
395
396 /* Used with application streams to save info about all app streams to
397 * create and send log-records to.
398 */
399 struct {
400 SaNameT logStreamName;
401 SaLogRecordT logRecord;
402 } stream_info[MAX_NUM_STREAM];
403
404 SaLogBufferT logBuffer[MAX_NUM_STREAM];
405 SaLogFileCreateAttributesT_2 logFileCreateAttributes[MAX_NUM_STREAM];
406 SaLogFileCreateAttributesT_2 *logFileCreateAttributes_ptr = NULL;
407 bool is_appl_stream = false;
408
409 srandom(getpid());
410
411 if (gethostname(hostname, _POSIX_HOST_NAME_MAX) == -1) {
412 fprintf(stderr, "gethostname failed: %s\n", strerror(errno));
413 exit(EXIT_FAILURE);
414 }
415
416 if (snprintf((char *)logSvcUsrName.value, SA_MAX_NAME_LENGTH,
417 "%s.%u@%s", "saflogtest", getpid(),
419 fprintf(stderr, "warning: truncation occurred with logSvcUsrName: %s", logSvcUsrName.value);
420 }
421 logSvcUsrName.length = strlen((char *)logSvcUsrName.value);
422
423 while (1) {
424 int c = getopt_long(argc, argv, "eohklnya:b:s:i:c:", long_options,
425 NULL);
426 if (c == -1) {
427 break;
428 }
429 switch (c) {
430 case 'e': /* Exit without closing any stream and without
431 finalize */
432 no_finalize_exit = true;
433 break;
434 case 'o': /* Open log stream and wait forever. Exit on Enter key
435 */
436 do_not_exit_f = true;
437 break;
438 case 'c':
439 write_count = atoi(optarg);
440 break;
441 case 'k':
442 wait_for_ack = false;
443 break;
444 case 'l':
445 strcpy((char *)stream_info[0].logStreamName.value,
447 stream_info[0].logStreamName.length =
448 strlen(SA_LOG_STREAM_ALARM);
449 if (optind < argc) {
450 log_message = argv[optind];
451 } else {
452 log_message = NULL;
453 }
454 create_log_record(&stream_info[0].logRecord,
456 &notificationClassId, log_message,
457 &logBuffer[0]);
458 stream_cnt = 1;
459 break;
460 case 'n':
461 strcpy((char *)stream_info[0].logStreamName.value,
463 stream_info[0].logStreamName.length =
465 if (optind < argc) {
466 log_message = argv[optind];
467 } else {
468 log_message = NULL;
469 }
470 create_log_record(&stream_info[0].logRecord,
472 &notificationClassId, log_message,
473 &logBuffer[0]);
474 stream_cnt = 1;
475 break;
476 case 'y':
477 strcpy((char *)stream_info[0].logStreamName.value,
479 stream_info[0].logStreamName.length =
480 strlen(SA_LOG_STREAM_SYSTEM);
481 if (optind < argc) {
482 log_message = argv[optind];
483 } else {
484 log_message = NULL;
485 }
486 create_log_record(&stream_info[0].logRecord,
488 &notificationClassId, log_message,
489 &logBuffer[0]);
490 stream_cnt = 1;
491 break;
492 case 'a':
493 if (stream_cnt >= MAX_NUM_STREAM) {
494 printf("Max %d streams can be opened\n",
496 break;
497 }
498 is_appl_stream = true;
500 &logFileCreateAttributes[stream_cnt], optarg);
501 logStreamOpenFlags = SA_LOG_STREAM_CREATE;
502 sprintf(
503 (char *)stream_info[stream_cnt].logStreamName.value,
504 "safLgStr=%s", optarg);
505 stream_info[stream_cnt].logStreamName.length =
506 strlen((char *)stream_info[stream_cnt]
507 .logStreamName.value);
508 if (optind < argc) {
509 if (strcmp(argv[optind], "-a") != 0) {
510 log_message = argv[optind];
511 } else {
512 log_message = NULL;
513 }
514 } else {
515 log_message = NULL;
516 }
517 create_log_record(&stream_info[stream_cnt].logRecord,
519 &notificationClassId, log_message,
520 &logBuffer[stream_cnt]);
521 stream_cnt++;
522 break;
523 case 'b':
524 sprintf((char *)stream_info[0].logStreamName.value,
525 "safLgStrCfg=%s", optarg);
526 strcat((char *)stream_info[0].logStreamName.value,
527 ",safApp=safLogService");
528 stream_info[0].logStreamName.length =
529 strlen((char *)stream_info[0].logStreamName.value);
530 if (optind < argc) {
531 log_message = argv[optind];
532 } else {
533 log_message = NULL;
534 }
535 create_log_record(&stream_info[0].logRecord,
537 &notificationClassId, log_message,
538 &logBuffer[0]);
539 stream_cnt = 1;
540 break;
541 case 's':
542 logSeverity = get_severity(optarg);
543 break;
544 case 'i':
545 interval = atoi(optarg);
546 break;
547 case 'h':
548 case '?':
549 default:
550 usage();
551 exit(EXIT_FAILURE);
552 break;
553 }
554 }
555
556 struct timespec timeout_time;
557 osaf_set_millis_timeout(kWaitTime, &timeout_time);
558 while(!osaf_is_timeout(&timeout_time)) {
561 if (error != SA_AIS_ERR_TRY_AGAIN) break;
563 }
564 if (error != SA_AIS_OK) {
565 fprintf(stderr, "saLogInitialize FAILED: %s\n",
566 saf_error(error));
567 exit(EXIT_FAILURE);
568 }
569
571 if (error != SA_AIS_OK) {
572 exit(EXIT_FAILURE);
573 }
574
575 int j;
576 for (j = 0; j < stream_cnt; j++) {
577 if (stream_info[j].logRecord.logHdrType ==
579 stream_info[j]
580 .logRecord.logHeader.genericHdr.logSeverity =
581 logSeverity;
582 }
583
584 if (is_appl_stream) {
585 logFileCreateAttributes_ptr =
586 &logFileCreateAttributes[j];
587 } else {
588 logFileCreateAttributes_ptr = NULL;
589 }
590
591 osaf_set_millis_timeout(kWaitTime, &timeout_time);
592 while(!osaf_is_timeout(&timeout_time)) {
593 error = saLogStreamOpen_2(
594 logHandle, &stream_info[j].logStreamName,
595 logFileCreateAttributes_ptr,
596 logStreamOpenFlags,
598 if (error != SA_AIS_ERR_TRY_AGAIN) break;
600 }
601
602 if (error != SA_AIS_OK) {
603 fprintf(stderr, "saLogStreamOpen_2 FAILED: %s\n",
604 saf_error(error));
605 exit(EXIT_FAILURE);
606 }
607 free_logFileCreateAttributes(logFileCreateAttributes_ptr);
608
609 if (stream_info[j].logRecord.logBuffer->logBuf != NULL) {
610 for (i = 0; i < write_count; i++) {
613 &stream_info[j].logRecord, wait_for_ack);
614 if (interval > 0) {
615 struct timespec sleep_time;
616 sleep_time.tv_sec = interval / 1000000;
617 sleep_time.tv_nsec =
618 (interval % 1000000) * 1000;
619 osaf_nanosleep(&sleep_time);
620 }
621 }
622 }
623
624 free_loc_record(&stream_info[j].logRecord);
625 } /* loop j < stream_cnt */
626
627 /* Wait for key press (any key) before closing stream(s) and or finalize
628 */
629 if (do_not_exit_f == true) {
630 printf(
631 "\nPress 'Enter' to close stream(s) finalize and exit...\n");
632 (void)getchar();
633 do_not_exit_f = false;
634 }
635
636 /* Exit without closing streams or finalize log API */
637 if (no_finalize_exit == true) {
638 printf("Exit witout stream close or finalize\n");
639 exit(EXIT_SUCCESS);
640 }
641
642 /* If only one stream is open it's closed before Finalize
643 * If there are several open streams, just Finalize (streams will be
644 * closed automatically)
645 */
646 if (stream_cnt == 1) {
647 osaf_set_millis_timeout(kWaitTime, &timeout_time);
648 while(!osaf_is_timeout(&timeout_time)) {
650 if (error != SA_AIS_ERR_TRY_AGAIN) break;
652 }
653 if (error != SA_AIS_OK) {
654 fprintf(stderr, "saLogStreamClose FAILED: %s\n",
655 saf_error(error));
656 exit(EXIT_FAILURE);
657 }
658 }
659
660 osaf_set_millis_timeout(kWaitTime, &timeout_time);
661 while(!osaf_is_timeout(&timeout_time)) {
662 error = saLogFinalize(logHandle);
663 if (error != SA_AIS_ERR_TRY_AGAIN) break;
665 }
666 if (error != SA_AIS_OK) {
667 fprintf(stderr, "saLogFinalize FAILED: %s\n", saf_error(error));
668 exit(EXIT_FAILURE);
669 }
670
671 exit(EXIT_SUCCESS);
672}
static struct pollfd fds[FD_IMM+1]
Definition: main.cc:85
SaSelectionObjectT selectionObject
Definition: amftest.c:22
SaLogStreamHandleT logStreamHandle
Definition: logtest.c:94
SaLogHandleT logHandle
Definition: logtest.c:93
SaNameT logSvcUsrName
Definition: logtest.c:76
const char * hostname(void)
Definition: logutil.c:26
#define printf
Definition: mdstipc_api.c:58
static SaNtfSeverityT severity
Definition: ntfread.c:77
SaVersionT version
Definition: ntfsend.c:42
static const char * saf_error[]
Definition: util.c:25
const struct timespec kHundredMilliseconds
Definition: osaf_time.c:28
void osaf_nanosleep(const struct timespec *sleep_duration)
Sleep for the specified time.
Definition: osaf_time.c:37
This file contains utility functions related to time and time conversion.
static void osaf_set_millis_timeout(uint64_t i_millis, struct timespec *o_ts)
Set a time i_millis in the future.
Definition: osaf_time.h:429
static bool osaf_is_timeout(const struct timespec *i_ts)
Inform if the time given in i_ts is passed.
Definition: osaf_time.h:438
SaInt64T SaTimeT
Definition: saAis.h:56
@ SA_DISPATCH_ONE
Definition: saAis.h:91
@ SA_TRUE
Definition: saAis.h:87
SaAisErrorT
Definition: saAis.h:96
@ SA_AIS_ERR_TRY_AGAIN
Definition: saAis.h:102
@ SA_AIS_ERR_BAD_OPERATION
Definition: saAis.h:116
@ SA_AIS_OK
Definition: saAis.h:97
char * SaStringT
Definition: saAis.h:53
SaUint64T SaSelectionObjectT
Definition: saAis.h:60
#define SA_TIME_UNKNOWN
Definition: saAis.h:64
#define SA_MAX_NAME_LENGTH
Definition: saAis.h:75
unsigned char SaUint8T
Definition: saAis.h:45
SaUint64T SaInvocationT
Definition: saAis.h:57
#define SA_TIME_ONE_SECOND
Definition: saAis.h:68
#define SA_LOG_STREAM_ALARM
Definition: saLog.h:55
#define SA_LOG_RECORD_WRITE_ACK
Definition: saLog.h:94
SaUint64T SaLogStreamHandleT
Definition: saLog.h:50
@ SA_LOG_FILE_FULL_ACTION_ROTATE
Definition: saLog.h:180
#define SA_LOG_SEV_CRITICAL
Definition: saLog.h:64
#define SA_LOG_STREAM_NOTIFICATION
Definition: saLog.h:54
SaUint32T SaLogAckFlagsT
Definition: saLog.h:87
#define SA_LOG_SEV_NOTICE
Definition: saLog.h:67
#define SA_LOG_STREAM_SYSTEM
Definition: saLog.h:53
#define SA_LOG_SEV_INFO
Definition: saLog.h:68
#define SA_LOG_STREAM_CREATE
Definition: saLog.h:100
#define SA_LOG_SEV_EMERGENCY
Definition: saLog.h:62
#define SA_LOG_SEV_ALERT
Definition: saLog.h:63
#define SA_LOG_SEV_ERROR
Definition: saLog.h:65
SaUint64T SaLogHandleT
FILE: saLog.h.
Definition: saLog.h:49
#define SA_LOG_SEV_WARNING
Definition: saLog.h:66
SaLogHeaderTypeT
Definition: saLog.h:124
@ SA_LOG_NTF_HEADER
Definition: saLog.h:125
@ SA_LOG_GENERIC_HEADER
Definition: saLog.h:126
SaUint8T SaLogStreamOpenFlagsT
Definition: saLog.h:96
SaUint16T SaLogSeverityT
Definition: saLog.h:70
@ SA_NTF_ALARM_PROCESSING
Definition: saNtf.h:91
#define SA_NTF_IDENTIFIER_UNUSED
Definition: saNtf.h:172
int main(int argc, char *argv[])
Definition: saflogtest.c:362
#define MAX_NUM_STREAM
Definition: saflogtest.c:57
const uint64_t kWaitTime
Definition: saflogtest.c:59
static SaLogSeverityT get_severity(char *severity)
Definition: saflogtest.c:242
const SaVersionT kLogVersion
Definition: saflogtest.c:60
static SaAisErrorT write_log_record(SaLogHandleT logHandle, SaLogStreamHandleT logStreamHandle, SaSelectionObjectT selectionObject, const SaLogRecordT *logRecord, bool wait_for_ack)
Write log record to stream, wait for ack.
Definition: saflogtest.c:147
static void free_logFileCreateAttributes(SaLogFileCreateAttributesT_2 *logFileCreateAttributes)
Definition: saflogtest.c:354
#define DEFAULT_APP_LOG_REC_SIZE
Definition: saflogtest.c:52
static SaLogCallbacksT logCallbacks
Definition: saflogtest.c:64
#define DEFAULT_FORMAT_EXPRESSION
Definition: saflogtest.c:51
static void logWriteLogCallbackT(SaInvocationT invocation, SaAisErrorT error)
Definition: saflogtest.c:133
static void set_logFileCreateAttributes(SaLogFileCreateAttributesT_2 *logFileCreateAttributes, SaStringT logFileName)
Definition: saflogtest.c:337
static SaInvocationT cb_invocation
Definition: saflogtest.c:67
static SaTimeT get_current_SaTime(void)
Definition: saflogtest.c:70
#define DEFAULT_APP_LOG_FILE_SIZE
Definition: saflogtest.c:53
static void free_loc_record(SaLogRecordT *logRecord)
Definition: saflogtest.c:330
static char * progname
Definition: saflogtest.c:66
static void usage(void)
Definition: saflogtest.c:86
static SaAisErrorT cb_error
Definition: saflogtest.c:68
#define DEFAULT_MAX_FILES_ROTATED
Definition: saflogtest.c:55
static void create_log_record(SaLogRecordT *logRecord, SaLogHeaderTypeT logHdrType, SaNameT *logSvcUsrName, SaNtfClassIdT *notificationClassId, char *log_message, SaLogBufferT *logBuffer)
Creates a log record by filling in the log service API struct of type SaLogRecordT.
Definition: saflogtest.c:283
SaUint8T * logBuf
Definition: saLog.h:84
SaSizeT logBufSize
Definition: saLog.h:83
SaLogFileFullActionT logFileFullAction
Definition: saLog.h:192
SaUint32T maxLogRecordSize
Definition: saLog.h:190
SaNtfClassIdT * notificationClassId
Definition: saLog.h:149
SaLogSeverityT logSeverity
Definition: saLog.h:151
const SaNameT * logSvcUsrName
Definition: saLog.h:150
SaNtfEventTypeT eventType
Definition: saLog.h:136
SaNameT * notifyingObject
Definition: saLog.h:138
SaTimeT eventTime
Definition: saLog.h:140
SaNameT * notificationObject
Definition: saLog.h:137
SaNtfClassIdT * notificationClassId
Definition: saLog.h:139
SaNtfIdentifierT notificationId
Definition: saLog.h:135
SaTimeT logTimeStamp
Definition: saLog.h:164
SaLogHeaderTypeT logHdrType
Definition: saLog.h:169
SaLogHeaderT logHeader
Definition: saLog.h:170
SaLogBufferT * logBuffer
Definition: saLog.h:171
Definition: saAis.h:163
SaUint16T length
Definition: saAis.h:164
SaUint8T value[256]
Definition: saAis.h:165
static SaInvocationT invocation
SaLogNtfLogHeaderT ntfHdr
Definition: saLog.h:157
SaLogGenericLogHeaderT genericHdr
Definition: saLog.h:158