npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tslogger4frontend

v1.1.2

Published

记录前端日志并下载

Downloads

21

Readme

tsLog

记录前端日志并下载

基于 typescript 编写一款前端日志保存并下载插件。 前端日志使用 console 打印不易保存,项目中如使用 websocket 出现异常无法直接定位问题。

日志保存在 localstorage 中,低版本浏览器不兼容,只做开发调试用。 localstorage 大小有限(5M 左右),需要合理安排,仅打印关键部分,下载的日志文件推荐使用 notepad++ 查看。

配置介绍:

1、usetsLog:boolean 是否使用此插件,生产版本可由此参数控制不使用此功能,默认打开(true)。

2、doConsole:boolean 是否也在控制台内打印日志,默认不打印(false)。

3、itemName:string localstorage 自定义存储 key 值,默认 tsLog。

4、maxLen:number 日志存储条数上限,默认 500。

5、logName:string 下载日志文件名,默认 TSLOG,文件名自动添加时间及类型,形如 TSLOG20191107104143.txt。

暴露方法:

1、log:保存并打印一般日志

2、warn:保存并打印警告日志

3、error:保存并打印错误日志

4、downloadLog:保存并下载日志

5、clear:清空已保存的日志

示例:

1、安装

$ npm i tslogger4frontend -D

2、新建 logger.ts

import TsLog from "tslogger4frontend";
export default new TsLog();

3、在项目需要调试处使用,如在 app.tsx 中使用

import TsLog from "./logger.ts";

TsLog.log("11111");
TsLog.log("22222");
TsLog.log("33333");

TsLog.downloadLog();

即可下载文件如:TSLOG20191107104143.txt

-----TSLOG START-----

2019-11-07 10:41:43 INFO:11111

2019-11-07 10:41:43 INFO:22222

2019-11-07 10:41:43 INFO:33333

-----TSLOG END-----