@@ -533,7 +533,7 @@ def _search_and_format(
533
533
time_end : datetime .datetime = None ,
534
534
limit : int = LOG_RECORDS_LIMIT ,
535
535
sort_by : str = "datetime" ,
536
- sort_order : str = SortOrder .DESC ,
536
+ sort_order : str = SortOrder .ASC ,
537
537
log_filter : str = None ,
538
538
):
539
539
"""Returns the formatted log records.
@@ -550,7 +550,7 @@ def _search_and_format(
550
550
Maximum number of records to be returned.
551
551
sort_by: (str, optional). Defaults to "datetime"
552
552
The field for sorting the logs.
553
- sort_order: (str, optional). Defaults to "DESC ".
553
+ sort_order: (str, optional). Defaults to "ASC ".
554
554
The sort order for the log records. Can be "ASC" or "DESC".
555
555
log_filter : (str, optional). Defaults to None.
556
556
Expression for filtering the logs.
@@ -574,8 +574,8 @@ def _search_and_format(
574
574
sort_order = sort_order ,
575
575
log_filter = log_filter ,
576
576
)
577
- logs = sorted (( log . data for log in logs ), key = lambda x : x . get ( "datetime" ))
578
- logs = [log .get ("logContent" , {}) for log in logs ]
577
+
578
+ logs = [log .data . get ("logContent" , {}) for log in logs ]
579
579
return [
580
580
{
581
581
"id" : log .get ("id" ),
@@ -617,7 +617,7 @@ def tail(
617
617
return self ._search_and_format (
618
618
source = source ,
619
619
limit = limit ,
620
- sort_order = SortOrder .DESC ,
620
+ sort_order = SortOrder .ASC ,
621
621
time_start = time_start ,
622
622
log_filter = log_filter ,
623
623
)
@@ -808,7 +808,7 @@ def stream(
808
808
logs = self ._search_and_format (
809
809
source = source ,
810
810
limit = None ,
811
- sort_order = SortOrder .DESC ,
811
+ sort_order = SortOrder .ASC ,
812
812
time_start = time_start ,
813
813
log_filter = log_filter ,
814
814
)
@@ -858,7 +858,7 @@ def tail(
858
858
self ._search_and_format (
859
859
source = source ,
860
860
limit = limit ,
861
- sort_order = SortOrder .DESC ,
861
+ sort_order = SortOrder .ASC ,
862
862
time_start = time_start ,
863
863
log_filter = log_filter ,
864
864
)
@@ -927,7 +927,7 @@ def search(
927
927
time_end : datetime .datetime = None ,
928
928
limit : int = None ,
929
929
sort_by : str = "datetime" ,
930
- sort_order : str = SortOrder .DESC ,
930
+ sort_order : str = SortOrder .ASC ,
931
931
log_filter : str = None ,
932
932
) -> List [oci .loggingsearch .models .SearchResult ]:
933
933
"""Searches raw logs.
@@ -951,7 +951,7 @@ def search(
951
951
Defaults to "datetime"
952
952
sort_order : str, optional.
953
953
The sort order for the log records. Can be "ASC" or "DESC".
954
- Defaults to "DESC ".
954
+ Defaults to "ASC ".
955
955
log_filter : str, optional
956
956
Expression for filtering the logs. This will be the WHERE clause of the query.
957
957
Defaults to None.
@@ -979,7 +979,7 @@ def _search_and_format(
979
979
time_end : datetime .datetime = None ,
980
980
limit : int = LOG_RECORDS_LIMIT ,
981
981
sort_by : str = "datetime" ,
982
- sort_order : str = SortOrder .DESC ,
982
+ sort_order : str = SortOrder .ASC ,
983
983
log_filter : str = None ,
984
984
need_format : bool = True ,
985
985
) -> List [Union [oci .loggingsearch .models .SearchResult , dict ]]:
@@ -1005,7 +1005,7 @@ def _search_and_format(
1005
1005
Defaults to "datetime"
1006
1006
sort_order : str, optional.
1007
1007
The sort order for the log records. Can be "ASC" or "DESC".
1008
- Defaults to "DESC ".
1008
+ Defaults to "ASC ".
1009
1009
log_filter : str, optional
1010
1010
Expression for filtering the logs. This will be the WHERE clause of the query.
1011
1011
Defaults to None.
@@ -1039,12 +1039,6 @@ def _search_and_format(
1039
1039
)
1040
1040
)
1041
1041
1042
- # _collect_logs returns a list of either dict or oci.loggingsearch.models.SearchResult
1043
- # objects based on `need_format` parameter, so below there are two cases for log sorting.
1044
- if need_format :
1045
- batch_logs .sort (key = lambda x : x .get ("datetime" ))
1046
- else :
1047
- batch_logs .sort (key = lambda x : x .data .get ("datetime" ))
1048
1042
if limit and len (batch_logs ) > limit :
1049
1043
batch_logs = batch_logs [:limit ]
1050
1044
return batch_logs
@@ -1057,7 +1051,7 @@ def _collect_logs(
1057
1051
time_end : datetime .datetime = None ,
1058
1052
limit : int = LOG_RECORDS_LIMIT ,
1059
1053
sort_by : str = "datetime" ,
1060
- sort_order : str = SortOrder .DESC ,
1054
+ sort_order : str = SortOrder .ASC ,
1061
1055
log_filter : str = None ,
1062
1056
need_format : bool = True ,
1063
1057
) -> List [Union [oci .loggingsearch .models .SearchResult , dict ]]:
@@ -1085,7 +1079,7 @@ def _collect_logs(
1085
1079
Defaults to "datetime"
1086
1080
sort_order : str, optional.
1087
1081
The sort order for the log records. Can be "ASC" or "DESC".
1088
- Defaults to "DESC ".
1082
+ Defaults to "ASC ".
1089
1083
log_filter : str, optional
1090
1084
Expression for filtering the logs. This will be the WHERE clause of the query.
1091
1085
Defaults to None.
0 commit comments