0.0.4 • Published 6 years ago

vue-logger v0.0.4

Weekly downloads
240
License
MIT
Repository
github
Last release
6 years ago

Vue logger

Ci Version License Downloads

文档(Document): English

适用于 vue 1.x 和 2.x

安装

npm install vue-logger --save

使用

引入

import vueLogger from "vue-logger";
Vue.use(vueLogger, {
  prefix: () => new Date(),
  dev: true,
  shortname: true,
  levels: ["log", "warn", "debug", "error", "dir"],
  forceLevels: []
});

调用

export default {
  mounted() {
    // 当 shortname 为 true 时, 默认为true
    this.$error("hello world");

    // 全局使用
    Vue.console.log("hello world");
  }
};

默认 levels ['log', 'warn', 'debug', 'error', 'dir'], 你可以额外添加,

Vue.use(vueLogger, { levels: ["info"] });

// 在组件中使用
this.$info("hello world");
// log依旧可以使用
this.$log("hello world");

关于shortname,默认是 true,如果不想要别名,可以这么调用

this.$console.log();

Options

NameTypeDefaultDesc
prefixstringNone日志前缀,可以通过 function动态添加
devbooleantrue日志开关,可选择在生产环境中关闭
shortnamebooleantrue
levelsarray'log', 'warn', 'debug', 'error', 'dir'
forceLevelsarray[]无视 dev 的配置 强制打印

开发

# install deps
npm install

# build dist files
npm run build

# run all tests
npm test

TODO

  • sentry
0.0.4

6 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

1.0.0

7 years ago