Skip to content

Commit bda292d

Browse files
committed
sys/log: Address review comments
- Fix syscfg description - Remove log_trailer_data_len API and underlying callback as it doesn't get used anywhere - Revert API protoype style change in log.h
1 parent b594e7f commit bda292d

File tree

3 files changed

+19
-36
lines changed

3 files changed

+19
-36
lines changed

sys/log/full/include/log/log.h

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,6 @@ typedef int log_process_trailer_func_t(struct log *log, void *arg, const void *d
135135
*/
136136
typedef uint16_t log_trailer_len_func_t(struct log *log, const struct log_entry_hdr *hdr);
137137

138-
/** @typedef log_trailer_data_len_func_t
139-
* @brief Callback used to read length of trailer data in a log entry
140-
*
141-
* @param log The log the trailer is to be read from
142-
* @param hdr Log entry header of the log entry the log is
143-
* read from
144-
* @return Length of the appended trailer data
145-
*/
146-
typedef uint16_t log_trailer_data_len_func_t(struct log *log, const struct log_entry_hdr *hdr);
147-
148138
/** @typedef log_trailer_reset_data_func_t
149139
* @brief Callback used to reset trailer data per log
150140
*
@@ -311,11 +301,23 @@ STATS_SECT_END
311301

312302
/* Trailer support callbacks */
313303
struct log_trailer_handler {
304+
/* Trailer length callback used to get the length of the trailer from provided
305+
* log entry
306+
*/
314307
log_trailer_len_func_t *log_trailer_len;
315-
log_trailer_data_len_func_t *log_trailer_data_len;
308+
/* Trailer append callback used to append trailer to the log entry */
316309
log_trailer_append_func_t *log_trailer_append;
310+
/* Trailer process callback used to process trailer from the log entry
311+
* which gets called at various places where the log entry gets read
312+
*/
317313
log_process_trailer_func_t *log_process_trailer;
314+
/* Trailer mbuf append callback used to append trailer to the log entry
315+
* using the mbufs
316+
*/
318317
log_trailer_mbuf_append_func_t *log_trailer_mbuf_append;
318+
/* Trailer reset data callback used to reset the trailer data
319+
* per log which is defined by the application registering these callbacks
320+
*/
319321
log_trailer_reset_data_func_t *log_trailer_reset_data;
320322
};
321323

@@ -663,7 +665,8 @@ int log_read_hdr(struct log *log, const void *dptr, struct log_entry_hdr *hdr);
663665
*
664666
* @return Length of the header
665667
*/
666-
uint16_t log_hdr_len(const struct log_entry_hdr *hdr);
668+
uint16_t
669+
log_hdr_len(const struct log_entry_hdr *hdr);
667670

668671
/**
669672
* @brief Reads data from the body of a log entry into a flat buffer.
@@ -881,15 +884,6 @@ int log_len_in_medium(struct log *log, uint16_t len);
881884
*/
882885
uint16_t log_trailer_len(struct log *log, const struct log_entry_hdr *hdr);
883886

884-
/**
885-
* @brief Reads the trailer data length
886-
*
887-
* @param hdr Ptr to the header
888-
*
889-
* @return Length of the trailer data
890-
*/
891-
uint16_t log_trailer_data_len(struct log *log, const struct log_entry_hdr *hdr);
892-
893887
/**
894888
* @brief Append trailer to the log entry
895889
*

sys/log/full/src/log.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -524,19 +524,6 @@ log_trailer_len(struct log *log, const struct log_entry_hdr *hdr)
524524
return 0;
525525
}
526526

527-
uint16_t
528-
log_trailer_data_len(struct log *log, const struct log_entry_hdr *hdr)
529-
{
530-
if (log->l_th) {
531-
if (log->l_th->log_trailer_data_len) {
532-
return log->l_th->log_trailer_data_len(log, hdr);
533-
} else {
534-
return 0;
535-
}
536-
}
537-
return 0;
538-
}
539-
540527
int
541528
log_trailer_append(struct log *log, uint8_t *buf, uint16_t *buflen,
542529
void *loc, uint16_t *f_offset)
@@ -692,7 +679,9 @@ log_append_prepare(struct log *log, uint8_t module, uint8_t level,
692679
#endif
693680

694681
#if MYNEWT_VAL(LOG_FLAGS_TRAILER_SUPPORT)
695-
ue->ue_flags |= LOG_FLAGS_TRAILER_SUPPORT;
682+
if (log->l_th) {
683+
ue->ue_flags |= LOG_FLAGS_TRAILER_SUPPORT;
684+
}
696685
#endif
697686

698687
err:

sys/log/full/syscfg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ syscfg.defs:
6565

6666
LOG_FLAGS_TRAILER_SUPPORT:
6767
description: >
68-
Enable logging TLV with custom data types in every log entry
68+
Enable logging trailer with custom data types in every log entry
6969
0 - disable; 1 - enable.
7070
value: 0
7171

0 commit comments

Comments
 (0)