File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Original file line number Diff line number Diff line change
1
+ #!/bin/env python3
2
+
3
+ import redis
4
+ import json
5
+ import os
6
+ from datetime import datetime
7
+
8
+ logDir = '/var/log/llama.cpp'
9
+ logJsonName = 'llama.log'
10
+ logJsonFile = os .path .join (logDir , logJsonName )
11
+
12
+ if not os .path .exists (logDir ):
13
+ os .makedirs (logDir )
14
+
15
+ rediscon = redis .StrictRedis (host = '127.0.0.1' , port = 6379 , db = 0 )
16
+ print (rediscon )
17
+
18
+ with open (logJsonFile , 'a' ) as fJson :
19
+ while True :
20
+ logDataStr = rediscon .blpop ('llama.cpp' )[1 ].decode ('utf8' )
21
+ ts = datetime .now ().strftime ('%Y-%m-%d %H:%M:%S.%f' )
22
+ logDict = {'time' :ts , 'log' :json .loads (logDataStr )}
23
+ logJsonStr = json .dumps (logDict , indent = 4 , ensure_ascii = False )
24
+ fJson .write (logJsonStr + '\n ' )
25
+ fJson .flush ()
26
+
You can’t perform that action at this time.
0 commit comments