Coder Social home page Coder Social logo

web-logger-js's Introduction

web-logger

a js library for web application store log and send log

usage

option one

git clone
npm i
npm run build

copy dist/web-logger-js.js to your project

option two

npm i web-logger-js
import Logger from "web-logger-js"

notice

web-logger required token before send logs to your backend server,web-logger built-in sending enqueue.

setup

in vue project main.js

import Vue from 'vue';
import { createRouter } from "vue-router"
import Logger from "web-logger-js"

const router = createRouter()
const logger = new Logger({
  saveToCloud: true, 
  sourceType: "h5", 
  projectName: "xxx", 
  env: "test", 
  encrypt: true, 
  reportUrl: "http://xxx.xxxx.xxxx", 
  router: router
})
Vue.prototype.$logger = logger;

in anywhere

<script>
export default {
    created() {
      this.$logger.setToken("Bearer xxxxxx")
      this.$logger.info("app created")
    },
    mounted() {
      this.$logger.info("app mounted")
    }
};
</script>

options

const option = {
	saveToCloud: false, // enable upload log to server,default false
	sourceType: "web", // web/h5
	projectName: "", // current project name,
	env: "test", // current project env
	encrypt: false, // enable 1024 RSA encrypt,default false
	reportUrl: '', // logs server url
	router: "", // vue-router
}

log message

message store in localstorage looks like

{
  "message": "",
  "level": "",
  "timestamp": "",
  "stacktrace": "",
  "userAgent": "",
  "projectName": "",
  "fullPath": "",
  "location": ""
}

API

  • setToken (if you need send to your server)
logger.setToken("Bearer xxxxx")
  • info
logger.info("text")
  • error
logger.error(e)

web-logger-js's People

Contributors

dusuwen avatar

Watchers

 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.