Skip to content

Commit 916a7f5

Browse files
authored
Fixed tail logging (#886)
2 parents f73a6d7 + 80fc0c8 commit 916a7f5

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

ads/common/oci_logging.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,14 @@ def tail(
614614
A list of log records.
615615
Each log record is a dictionary with the following keys: `id`, `time`, `message`.
616616
"""
617-
return self._search_and_format(
617+
tail_logs = self._search_and_format(
618618
source=source,
619619
limit=limit,
620-
sort_order=SortOrder.ASC,
620+
sort_order=SortOrder.DESC,
621621
time_start=time_start,
622622
log_filter=log_filter,
623623
)
624+
return sorted(tail_logs, key=lambda log: log["time"])
624625

625626
def head(
626627
self,
@@ -854,14 +855,15 @@ def tail(
854855
Expression for filtering the logs. This will be the WHERE clause of the query.
855856
Defaults to None.
856857
"""
858+
tail_logs = self._search_and_format(
859+
source=source,
860+
limit=limit,
861+
sort_order=SortOrder.DESC,
862+
time_start=time_start,
863+
log_filter=log_filter,
864+
)
857865
self._print(
858-
self._search_and_format(
859-
source=source,
860-
limit=limit,
861-
sort_order=SortOrder.ASC,
862-
time_start=time_start,
863-
log_filter=log_filter,
864-
)
866+
sorted(tail_logs, key=lambda log: log["time"])
865867
)
866868

867869
def head(

0 commit comments

Comments
 (0)