Advertisement
picles

logs

Nov 27th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let daily_path = 'logs\\daily\\',
  2.     time_path = 'logs\\alltime\\',
  3.     today,
  4.     total
  5.    
  6. function getToday(){
  7.   return moment().tz('America/Sao_Paulo').format("DD-MM-YYYY")
  8. }
  9.  
  10. let log = {
  11.   daily: {
  12.     get: ()=>{
  13.       try {
  14.         let today = jsonfile.readFileSync(daily_path + getToday() + '.json')
  15.         return today
  16.       }catch(e){
  17.         let today = {
  18.           base: 0,
  19.           character: 0,
  20.           effect:0,
  21.           etc:0,
  22.           item:0,
  23.           list:0,
  24.           map:0,
  25.           mob:0,
  26.           morph:0,
  27.           npc:0,
  28.           quest:0,
  29.           reactor:0,
  30.           skill:0,
  31.           sound:0,
  32.           string:0,
  33.           tamingmob:0,
  34.           ui:0,
  35.           x86: 0,
  36.           x64: 0,
  37.           altered: 0
  38.         }
  39.         return today
  40.       }
  41.     },
  42.     save: ()=>{
  43.       try{
  44.         jsonfile.writeFileSync(daily_path + getToday() + '.json')
  45.       }catch(e){
  46.         console.log('Error saving daily log')
  47.       }
  48.     }
  49.   },
  50.   total: {
  51.     get: ()=>{
  52.       try {
  53.         let total = jsonfile.readFileSync(total_path + '.json')
  54.         return total
  55.       }catch(e){
  56.         let total = {
  57.           base: 0,
  58.           character: 0,
  59.           effect:0,
  60.           etc:0,
  61.           item:0,
  62.           list:0,
  63.           map:0,
  64.           mob:0,
  65.           morph:0,
  66.           npc:0,
  67.           quest:0,
  68.           reactor:0,
  69.           skill:0,
  70.           sound:0,
  71.           string:0,
  72.           tamingmob:0,
  73.           ui:0,
  74.           x86: 0,
  75.           x64: 0,
  76.           altered,
  77.           verify
  78.         }
  79.         return total
  80.       }
  81.     },
  82.     save: ()=>{
  83.       try{
  84.         jsonfile.writeFileSync(total_path + '.json')
  85.       }catch(e){
  86.         console.log('Error saving all-time log')
  87.       }
  88.     }
  89.   }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement