浏览代码

feature:优化日志解压缩的脚本

#Suyghur 4 年之前
父节点
当前提交
86320e2cf7

+ 0 - 16
library_zap/log_utils/decompress_log.py

@@ -1,16 +0,0 @@
-import zlib
-
-
-def decompress_zlib(src, dst):
-    src = open(src, "rb+")
-    dst = open(dst, "wb+")
-    handler = zlib.decompressobj(-zlib.MAX_WBITS)
-    data = src.read(1024)
-    while data:
-        dst.write(handler.decompress(data))
-        data = src.read(1024)
-    dst.write(str(handler.flush))
-
-
-if __name__ == "__main__":
-    decompress_zlib("2021-04-15-zap","test.log")

+ 20 - 0
library_zap/shell/decompress_log.py

@@ -0,0 +1,20 @@
+import zlib
+import os
+import sys
+
+
+def decompress(args):
+    decompressor = zlib.decompressobj(-zlib.MAX_WBITS)
+    src = args[0]
+    dst = args[1]
+    _buffer = []
+    with open(src, "rb") as src_fp:
+        _buffer = bytearray(os.path.getsize(src))
+        src_fp.readinto(_buffer)
+    with open(dst, "w+") as dst_fp:
+        tmp = decompressor.decompress(str(_buffer))
+        dst_fp.write(tmp)
+
+
+if __name__ == "__main__":
+    decompress(sys.args[1:])

+ 8 - 0
library_zap/src/main/java/com/dolin/zap/impl/LogCleaner.kt

@@ -0,0 +1,8 @@
+package com.dolin.zap.impl
+
+/**
+ * @author #Suyghur.
+ * Created on 4/15/21
+ */
+class LogCleaner {
+}