First plugin test...
Created
April 7, 2016 00:53
-
-
Save ZeroDragon/14117b15d1517451894c3d5d819f35f3 to your computer and use it in GitHub Desktop.
ChaiTea Plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'chaitea-framework' | |
require './plugins' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###* | |
* Console With Time | |
### | |
df = "yyyy/mm/dd HH:MM:ss" | |
util = require 'util' | |
logger = (arg)-> process.stdout.write(arg) | |
printer = (type,logs)-> | |
d = ~~(new Date().getTime()/1000) | |
addZ = (i)-> ('00'+i).slice(-2) | |
t = "[#{CT_DateFormat(d,df)}]"[type] | |
if logs.length is 1 | |
te = logs[0] | |
if typeof(logs[0]) is 'object' | |
te = util.inspect(logs[0]) | |
te = te | |
logger "#{t} #{te}\n" | |
else | |
logs = logs.map (e)-> | |
if typeof(e) is 'object' | |
return util.inspect(e) | |
else | |
return e | |
logger "#{t} #{logs.join(' ')}\n" | |
console.log = (logs...)-> printer 'blue',logs | |
console.error = (logs...)-> printer 'red',logs | |
console.warn = (logs...)-> printer 'yellow',logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p = require("path") | |
normalizedPath = p.join(__dirname) | |
require('fs').readdirSync(normalizedPath).forEach (file) -> | |
if file isnt 'index.coffee' | |
require p.join(normalizedPath,file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment