/*
 * @Descripttion: HJ
 * @Company: 思宏科技
 * @version: v1.0
 * @Author: HJ
 * @Date: 2021-08-03 14:30:25
 * @LastEditors: HJ
 * @LastEditTime: 2021-08-03 13:54:51
 */
class Log {
  constructor() {
    this._log = wx.getRealtimeLogManager ? wx.getRealtimeLogManager() : console
  }

  info() {
    if (!this._log) return

    this._log.info.apply(this._log, arguments)
  }

  warn() {
    if (!this._log) return

    this._log.warn.apply(this._log, arguments)
  }

  error() {
    if (!this._log) return

    this._log.error.apply(this._log, arguments)
  }

  setFilterMsg(msg) {
    // 从基础库2.7.3开始支持
    if (!this._log || !this._log.setFilterMsg) return
    if (typeof msg !== 'string') return

    this._log.setFilterMsg(msg)
  }

  addFilterMsg(msg) {
    // 从基础库2.8.1开始支持
    if (!this._log || !this._log.addFilterMsg) return
    if (typeof msg !== 'string') return

    this._log.addFilterMsg(msg)
  }
}

uni.$log = new Log()
