-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyAppLogging.py
48 lines (42 loc) · 1.13 KB
/
MyAppLogging.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import datetime
import json
import random
import uuid
def log_order():
ts = datetime.datetime.now().isoformat()
message = {
"log_name": "myapp-order",
"order": {
"order_id": str(uuid.uuid4()),
"status": 2,
"amount": random.randint(10, 100) * 100,
"order_time": (
datetime.datetime.now()
- datetime.timedelta(
minutes=random.randint(0, 19), seconds=random.randint(0, 59)
)
).isoformat(),
"pay_time": ts,
},
"user": {
"uid": str(random.randint(1, 50)),
"anonymous": False,
},
"time": ts,
}
datetime.datetime.now().date()
log(json.dumps(message))
def log_login():
ts = datetime.datetime.now().isoformat()
message = {
"log_name": "myapp-login",
"user": {
"uid": str(random.randint(1, 50)),
"anonymous": False,
},
"time": ts,
"client_type": random.choice(["web", "ios"]),
}
log(json.dumps(message))
def log(message: str):
print(message)