Skip to content

生产代码中使用 print 而非日志框架 #27

@nookery

Description

@nookery

问题描述

StoreService.swift 中发现多处使用 print() 而非系统日志框架的情况。

发现的问题

文件: CisumApp/Core/Seivces/StoreService/StoreService.swift

使用 print() 的位置:

print("检查订阅状态")
print("products.subscriptions 是空的")
print("statuses 是空的,表示对于当前订阅组,没有订阅状态")
print("检查订阅状态 -> Subscribed")

问题分析

  • 生产环境使用 print() 无法控制日志级别
  • 日志无法被系统日志收集
  • 无法在发布版本中关闭
  • 影响性能(尤其是在频繁调用的代码中)

建议

  • 使用项目中已有的 OSLog 框架
  • 或使用项目自定义的 SuperLog 协议
  • 将日志级别设为 debuginfo,便于在发布版本中过滤

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions