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

fshows-logger

v3.0.15

Published

## 使用

Downloads

45

Readme

fsLogger 日志工具

使用

安装

npm install fshows-logger --save

demo

import FsLogger from 'fshows-logger'

const extra = {
  mode: 'my mode'
}
const logger = new FsLogger({
  project: 'fshows-ecs-tes', // Project名称。
  logstore: 'web-merchant-bsite-log-dev', // Logstore名称。
  data() { // 非必填
    return {
      AppId: `fs-web-project`,
      ...extra
    }
  }
})

// 如需上报IP信息,需调用初始化Ip信息的方法
logger.initIpInfo().then(() => {
  logger.log('INFO', '我是一条info日志1')
})


logger.log('INFO', '我是一条info日志')

logger.info('我是第二条info日志')

logger.warn('我是一条warn日志')
logger.error('我是一条error日志')
logger.error({ errorCode: 1009, errorMsg: '网络繁忙,请稍后再试' })

配置项

  • 是否上报平台信息(SystemInfo/Useragent) sendSysInfo true为上报 false为不上报 默认为true

  • 上报内容 data

    • 基础字段
      • AppId 应用ID, 默认为'fs-logger-default'
      • Content 上报内容,默认是空字符串
      • Level 日志级别,默认是INFO,大写字母
      • LocalMachineTime 本地上报时间
      • UserAgent 浏览器环境,上报浏览器信息, sendSysInfo为true的情况下上报
      • SystemInfo 小程序环境,上报系统信息, sendSysInfo为true的情况下上报
    • 其他自定义字段

| 参数名称 | 类型 | 是否必填 | 描述 | 默认值 | | ---- | ---- | ---- | ---- | ---- | | host | string | 否 | 所在地域的服务入口。例如cn-hangzhou.log.aliyuncs.com | cn-hangzhou.log.aliyuncs.com | | project | string | 是 | Project名称 | | | logstore | string | 是 | Logstore名称 | | | time | number | 否 | 发送日志的时间间隔,默认是10秒 | 10 | | count | number | 否 | 发送日志的数量大小,默认是10条 | 10 | | data | Object/Function | 否 | 上报的字段 | | | sendSysInfo | Boolean | 否 | 是否上报平台信息 | true |

方法

| 参数名称 | 类型 | 是否必填 | 描述 | 默认值 | | ---- | ---- | ---- | ---- | ---- | | reportType | OBJECT/STRING | 选填 | STRING:以字符串形式在content字段中进行上报 OBJECT:对象形式 | STRING |

initIpInfo 如需上报IP信息,需调用初始化Ip信息的方法。获取ip信息方法是异步的,返回一个promise对象

initIpInfo()

log 上报日志

log(level: string, content: string | object, reportType: 'OBJECT' | 'STRING')

info 上报level为info的日志

info(content: string | object, reportType: 'OBJECT' | 'STRING')

warn 上报level为warn的日志

warn(content: string | object, reportType: 'OBJECT' | 'STRING')

error 上报level为error的日志

error(content: string | object, reportType: 'OBJECT' | 'STRING')

updateInfo 修改上报字段信息

info参数是上报字段对象,接口定义如下:

updateInfo(info: ISendInfo)
interface ISendInfo {
  AppId?: string
  Content?: string | object
  Level?: string
  LocalMachineTime?: string | undefined
  UserAgent?: string
  SystemInfo?: string
  _SI_IP?: string
  _SI_GEO?: string
  [propName: string]: any
}