Skip to content

Commit d695207

Browse files
committed
add gen_record() method for create a new record
1 parent d20f194 commit d695207

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

splunklib/searchcommands/generating_command.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,15 @@ def _execute(self, ifile, process):
213213

214214
def _execute_chunk_v2(self, process, chunk):
215215
count = 0
216+
records = []
216217
for row in process:
218+
records.append(row)
219+
count+=1
220+
if count == self._record_writer._maxresultrows:
221+
break
222+
223+
count = 0
224+
for row in records:
217225
self._record_writer.write_record(row)
218226
count += 1
219227
if count == self._record_writer._maxresultrows:

splunklib/searchcommands/search_command.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ def add_field(self, current_record, field_name, field_value):
177177
self._record_writer.custom_fields.add(field_name)
178178
current_record[field_name] = field_value
179179

180+
def gen_record(self, **record):
181+
self._record_writer.custom_fields |= record.keys()
182+
return {**record}
183+
180184
record = Option(doc='''
181185
**Syntax: record=<bool>
182186

0 commit comments

Comments
 (0)