coder-dongjiayi / MXLogger

MXLogger 是基于mmap内存映射机制的跨平台日志库,支持AES CFB 128位加密,支持iOS Android Flutter。核心代码使用C/C++实现, Flutter端通过ffi调用,性能几乎与原生一致。 底层序列化使用Google开源的flat_buffers实现,高效稳定。
Other
142 stars 18 forks source link

能否支持5天一个文件储存呢? #4

Closed philos3 closed 1 year ago

philos3 commented 1 year ago

能否支持5天一个文件储存呢? ///按日多文件存储 storagePolicy: "yyyy_MM_dd",

那么就有5个log文件,其实不方便查询

coder-dongjiayi commented 1 year ago

yyyy_MM_dd

你可以使用 yyyy_ww 按周存储也就是按周存储,目前不支持自定义时间。我不确定你说的不方便查询具体指什么,你可以描述一下你的业务,看看怎么处理更合适

philos3 commented 1 year ago

按周能稍微好点,就是想要自定义时长保存一个文件,目前只能天和周选一种,在这之间的选择是不支持的。

philos3 commented 1 year ago

还有对于日存储的文件2023-01-01_mxlog.mx名字可以进行遍历过滤等操作,如果是按周保存的,名字规则又是如何的呢,有对应的doc文档吗

coder-dongjiayi commented 1 year ago

还有对于日存储的文件2023-01-01_mxlog.mx名字可以进行遍历过滤等操作,如果是按周保存的,名字规则又是如何的呢,有对应的doc文档吗 刚才我看了下代码,按周存似乎有点击问题 之前改动过以后我就没测,暂时先别用了。有时间我更新一下。自定义存储时长这个事情意义不大,短期内应该不会支持。你直接扫描diskpath 不就能获取到所有文件名了。

philos3 commented 1 year ago

storagePolicy: "yyyy_ww", 按周储存,直接崩溃了

F/libc (25855): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x2 in tid 25912 (1.ui), pid 25855 (ocpeed.dna.test)


Build fingerprint: 'HUAWEI/NAM-AL00/HWNAM:12/HUAWEINAM-AL00/103.0.0.163C00:user/release-keys' Revision: '0' ABI: 'arm64' Timestamp: 2023-01-09 16:43:47.819553367+0800 Process uptime: 0s Cmdline: com.niocpeed.dna.test pid: 25855, tid: 25912, name: 1.ui >>> com.niocpeed.dna.test <<< uid: 10423 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x2 Cause: null pointer dereference x0 0000000000000002 x1 000000730cc1c210 x2 0000000000000000 x3 000000730cc1c8f0 x4 0000000000000002 x5 000000730cc1c84c x6 2573252d64343025 x7 732573252d643430 x8 0000000000000002 x9 000000743789460c x10 0000000000000003 x11 000000743789c2da x12 0000000000000000 x13 0000000000000002 x14 0000000000000010 x15 0000000000000000 x16 000000743796cfe0 x17 00000074378f3380 x18 000000730bc44000 x19 000000730cc1c7b0 x20 0000007437970342 x21 00000000ffffffff x22 0000000000000000 x23 0000000000000002 x24 000000730cc1c230 x25 000000730cc1e000 x26 0000000000000005 x27 00000000ffffffff x28 000000730cc1cab8 x29 000000730cc1c730 lr 0000007437939130 sp 000000730cc1be70 pc 00000074378f3390 pst 0000000080001000 backtrace:

00 pc 0000000000083390 /apex/com.android.runtime/lib64/bionic/libc.so (__strlen_aarch64+16) (BuildId: e18cca17d252ede5b01226139ce195f2)

  #01 pc 00000000000c912c  /apex/com.android.runtime/lib64/bionic/libc.so (__vfprintf+5460) (BuildId: e18cca17d252ede5b01226139ce195f2)
  #02 pc 00000000000e648c  /apex/com.android.runtime/lib64/bionic/libc.so (vsnprintf+192) (BuildId: e18cca17d252ede5b01226139ce195f2)
  #03 pc 00000000000b356c  /apex/com.android.runtime/lib64/bionic/libc.so (__vsnprintf_chk+60) (BuildId: e18cca17d252ede5b01226139ce195f2)
  #04 pc 000000000002c97c  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #05 pc 000000000002c224  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > mxlogger_helper::string_format<int, int>(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, int, int)+76) (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #06 pc 000000000002a4d4  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (mxlogger::sinks::base_file_sink::handle_date_(policy::storage_policy)+604) (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #07 pc 0000000000029ec4  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (mxlogger::sinks::base_file_sink::base_file_sink(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, policy::storage_policy)+244) (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #08 pc 000000000002c9b4  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (mxlogger::sinks::mmap_sink::mmap_sink(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, policy::storage_policy)+16) (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #09 pc 0000000000027818  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (std::__ndk1::__shared_ptr_emplace<mxlogger::sinks::mmap_sink, std::__ndk1::allocator<mxlogger::sinks::mmap_sink> >::__shared_ptr_emplace<char const*&, policy::storage_policy>(std::__ndk1::allocator<mxlogger::sinks::mmap_sink>, char const*&, policy::storage_policy&&)+84) (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #10 pc 0000000000025b28  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (mxlogger::mxlogger::mxlogger(char const*, char const*, char const*, char const*, char const*, char const*)+264) (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #11 pc 0000000000025564  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (mxlogger::mxlogger::initialize_namespace(char const*, char const*, char const*, char const*, char const*, char const*, char const*)+324) (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #12 pc 0000000000020c10  /data/app/~~HTpe1WCk02_ISp3wil7GxA==/com.niocpeed.dna.test-jL5-zsG_uVC5TTKqlbMgVA==/lib/arm64/libmxlogger.so (flutter_mxlogger_initialize+28) (BuildId: 5d1f1120dba3f6294019c41d07a2468589281539)
  #13 pc 0000000000006794  [anon:dart-codespace]

Lost connection to device.

philos3 commented 1 year ago

改成yyyy_WW 大写就好了,建议string换成enum类别,底层调用用 enum.name

philos3 commented 1 year ago

storagePolicy: "yyyy_ww", 按周储存,名字是创建当天日期,往后计算七天的,名字打印如下:2023-01-09_mxlog.mx