<template>
  <div>
    <div v-for="(item,index) in items"
         :key="index">
       <div class="cItem" @click="onClickItem(item.name)">{{item.name}}</div>
    </div>
  </div>
</template>

<script>

import YxLogger from "../../../../utils/logger/index"

export default {
  data () {
    return {
      items:[
        {name:'console'},
        {name:'cache'},
        {name:'except1'},
        {name:'except2'},
      ],
    }
  },

  components: {
  },

  methods: {
    onClickItem (name) {
       if(name == 'console'){
         YxLogger.setOutputWay(YxLogger.OUTPUT_WAY_CONSOLE)
         YxLogger.debug(this,'onClickItem', 'this is debug logger')
         YxLogger.info(this,'onClickItem', 'this is info logger')
         YxLogger.warn(this,'onClickItem', 'this is warn logger')
         YxLogger.error(this,'onClickItem', 'this is error logger')
       }else if(name == 'cache'){
         YxLogger.setOutputWay(YxLogger.OUTPUT_WAY_CACHE)
         YxLogger.setMaxLogCacheCount(6)
         YxLogger.debug(this,'onClickItem', 'item01')
         YxLogger.debug(this,'onClickItem', "item02")
         YxLogger.debug(this,'onClickItem', "item03")
         console.log(YxLogger.getCache())

         //输出到缓存是先把日志缓存到数组，数组超过一定长度以后会保存缓存，
         //缓存保存的方式是覆盖
         //建议只吧错误日志和警告日志放缓存
       }else if(name == 'except1'){
         try{
           var tt = null;
           console.log(tt.name)
         }catch (err){
            YxLogger.writeExcept(this, err)
         }
       }else if(name == 'except2'){
         try{
           this.exMothod()
         }catch (err){
           YxLogger.writeExcept(this, err)
         }
       }

    },

    exMothod(){
      try{
        var tt = null;
        console.log(tt.name)
      }catch (err){
        throw (err)
      }
    }
  },

  created () {
    // let app = getApp()
  }
}
</script>

<style scoped>
  .cItem{
     width: 100%;
     line-height: 40px;
     padding-left: 10px;
     border-bottom: solid 1px #959595;
  }
</style>
