Giter Club home page Giter Club logo

log4s's Introduction

log4s

做这个工具是因为:

  • 某些时候看服务端日志太麻烦。
  • 测试小姐姐提Bug时,给的相关信息又无法分析出问题原因。

所以我做了这个工具,让测试小姐姐可以点击某个按钮,就能把日志下载下来,然后将日志附在Bug详情中。更加方便的排查问题。

特点

  • 支持>= ie10
  • 支持日志下载

安装

yarn add log4s

使用

import Log4s from 'log4s' 
// 或者 const Log4s from 'log4s'
// 或者 直接script https://cdn.jsdelivr.net/npm/[email protected]/dist/log4s.umd.js 引入到html中

let log = new Log4s()

log4s.log('你好')
log4s.log('你好 abc')
log4s.log('你好, def')
log4s.log('你好, ahha')
log4s.log('你好,a')
log4s.search('a')

日志下载后,内容如下:

12-19 21:23:43.882 你好
12-19 21:23:43.882 你好 abc
12-19 21:23:43.882 你好, def
12-19 21:23:43.882 你好, ahha
12-19 21:23:43.882 你好,a

Log4s(options) 配置

默认配置:

export default {
  maxLines: 2500,  // 最多纪录多少行日志
  lineMaxChars: 2500, // 每行日志最多允许多少个字符,超出会截取
  logFilename: 'log4s.log', // 下载时文件名称
  lineBreak: '\n', // 下载文件时,每行日志之间的换行符
  enableLog: true, // 是否启动日志记录功能
  needTimestamp: true // 每行日志是否需要时间戳
}

实例方法

let log = new Log4s()
  • log(string|object) 写日志
  • getAllLog() 获取所有日志
  • search(keyword) 按关键词搜索日志
  • cleanAll() 清空日志
  • download() 下载日志

log4s's People

Contributors

eventualbuddha avatar greenkeeper[bot] avatar julkue avatar qm3ster avatar rich-harris avatar rickhanlonii avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.