Skip to content

Commit

Permalink
update timestamp_seconds into timestamp for backward support to use t…
Browse files Browse the repository at this point in the history
…imestamp as public member variable

Change-Id: I1ac8c69040d55f463aa85bed6f6427a7ed4fe7a9
  • Loading branch information
Miaodric committed Oct 8, 2024
1 parent 61c2e31 commit 90bb9ff
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions aliyun/log/logitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class LogItem(object):

def __init__(self, timestamp=None, time_nano_part=None, contents=None):
nano_time = int(time.time() * 10**9)
self.timestamp_seconds = int(timestamp) if timestamp else int(nano_time / 1000000000)
self.timestamp = int(timestamp) if timestamp else int(nano_time / 1000000000)
# milliseconds
if self.timestamp_seconds > 1e10:
self.timestamp_seconds = int(self.timestamp_seconds / 1000.0)
if self.timestamp > 1e10:
self.timestamp = int(self.timestamp / 1000.0)
self.time_nano_part = int(time_nano_part) if time_nano_part else int(nano_time % 1000000000)
self.contents = copy.deepcopy(contents) if contents else []

Expand Down Expand Up @@ -59,7 +59,7 @@ def get_time(self):
:return: int, log time
"""
return self.timestamp_seconds
return self.timestamp

def get_time_nano_part(self):
""" Get log time nano part
Expand All @@ -76,7 +76,7 @@ def set_time(self, timestamp):
# milliseconds
if timestamp > 1e10:
timestamp = timestamp / 1000.0
self.timestamp_seconds = int(timestamp)
self.timestamp = int(timestamp)

def set_time_nano_part(self, time_nano_part):
""" Set log time nano part
Expand All @@ -86,5 +86,5 @@ def set_time_nano_part(self, time_nano_part):
self.time_nano_part = int(time_nano_part)

def log_print(self):
print('time', self.timestamp_seconds)
print('time', self.timestamp)
print('contents', self.contents)

0 comments on commit 90bb9ff

Please sign in to comment.