initial commit

This commit is contained in:
Kegan Myers 2014-03-06 15:11:01 -06:00
commit 914dffb0e9
11 changed files with 274 additions and 0 deletions

97
Gruntfile.js Normal file
View file

@ -0,0 +1,97 @@
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-typescript');
/*var sauceConf = {
linux: {opera: {low: 12, high: 12}, googlechrome: {low: 26, high: 32}, firefox: {low: 3, high: 27}},
"OS X 10.9": {googlechrome: {low: 31, high: 31}, firefox: {low: 4, high: 26}},
"OS X 10.8": {googlechrome: {low: 27, high: 32}, safari: {low: 6, high: 6}},
"OS X 10.6": {googlechrome: {low: 27, high: 32}, safari: {low: 5, high: 5}, firefox: {low: 3, high: 27}},
"Windows XP": {googlechrome: {low: 26, high: 32}, safari: {low: 3, high: 5}, opera: {low: 9, high: 12}, firefox: {low: 4, high: 27}},
"Windows 7": {googlechrome: {low: 26, high: 32}, safari: {low: 5, high: 5}, opera: {low: 9, high: 12}, firefox: {low: 4, high: 27}},
"Windows 8": {googlechrome: {low: 26, high: 32}, opera: {low: 9, high: 10}, firefox: {low: 4, high: 27}},
"Windows 8.1": {googlechrome: {low: 26, high: 32}, opera: {low: 9, high: 10}, firefox: {low: 4, high: 27}}
};
var sauceBrowsers = []. sauceLaunch = {};
for (var operatingSystem in sauceConf) {
for (var browser in sauceConf[operatingSystem]) {
for (var i = sauceConf[operatingSystem][browser].low; i < sauceConf[operatingSystem][browser].high; i++) {
//this is not used yet
sauceBrowsers.push((operatingSystem + "_" + browser + "_" + i).toLowerCase().replace(" ", "-"));
sauceLaunch[(operatingSystem + "_" + browser + "_" + i).toLowerCase().replace(" ", "-")] = {
base: "SauceLabs",
browserName: browser,
platform: operatingSystem,
version: "" + i
}
}
}
}*/
//TODO integrate with Sauce
var travisBrowsers = [];//sauceBrowsers.slice(0);
travisBrowsers.push("PhantomJS");
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
projectConfig: {
baseBuild: '<%= pkg.build.directory %>/<%= pkg.build.baseArtifact %>'
},
karma: {
options: {
configFile: "karma.conf.js"
},
local: {
singleRun: true,
browsers: ["Chrome", "PhantomJS"]
},
travis: {
singleRun: true,
browsers: travisBrowsers
},
watch: {
autoWatch: true,
browsers: ["PhantomJS", "Chrome"]
}
},
typescript: {
base: {
src: ["lib/**/*.ts"],
dest: "<%= projectConfig.baseBuild%>.js",
options: {
declaration: true,
sourcemap: true
}
}
},
uglify: {
base: {
options: {
sourceMap: true,
sourceMapIncludeSources: true,
inSourceMap: "<%= typescript.base.dest%>.map",
sourceMapName: "<%= projectConfig.baseBuild%>.min.js.map",
mangle: true,
beautify: false,
compress: true
},
files: {
'<%= projectConfig.baseBuild%>.min.js': [
'<%= typescript.base.dest %>'
]
}
}
}
});
grunt.registerTask('default', ['typescript']);
grunt.registerTask('build', ['build:base']);
grunt.registerTask('build:base', ['typescript:base', 'uglify:base']);
grunt.registerTask('test', ['karma:local']);
grunt.registerTask('test:local', ['karma:local', 'karma:local']);
grunt.registerTask('test:travis', ['build:base', 'karma:travis']);
};

20
build/typerlog.d.ts vendored Normal file
View file

@ -0,0 +1,20 @@
declare module TyperLog {
class TyperLog {
private static logLevel;
private static console;
static Log(message: string, level: TyperLogLevel, category?: string): void;
private static;
}
}
declare module TyperLog {
enum TyperLogLevel {
EMERGENCY = 0,
ALERT = 1,
CRITICAL = 2,
ERROR = 3,
WARNING = 4,
NOTICE = 5,
INFORMATIONAL = 6,
DEBUG = 7,
}
}

47
build/typerlog.js Normal file
View file

@ -0,0 +1,47 @@
var TyperLog;
(function (_TyperLog) {
var TyperLog = (function () {
function TyperLog() {
}
TyperLog.Log = function (message, level, category) {
if (typeof category === "undefined") { category = ""; }
if (level <= this.logLevel) {
TyperLog.console["log"](message);
}
};
TyperLog.logLevel = 4 /* WARNING */;
TyperLog.console = (function () {
var noop = function () {
};
var console = window.console || {};
console["log"] = window.console.log || noop;
console["trace"] = function () {
try {
throw {};
} catch (e) {
console["log"](e.trace);
}
};
console["debug"] = window.console.debug || noop;
return console;
})();
return TyperLog;
})();
_TyperLog.TyperLog = TyperLog;
})(TyperLog || (TyperLog = {}));
var TyperLog;
(function (TyperLog) {
(function (TyperLogLevel) {
TyperLogLevel[TyperLogLevel["EMERGENCY"] = 0] = "EMERGENCY";
TyperLogLevel[TyperLogLevel["ALERT"] = 1] = "ALERT";
TyperLogLevel[TyperLogLevel["CRITICAL"] = 2] = "CRITICAL";
TyperLogLevel[TyperLogLevel["ERROR"] = 3] = "ERROR";
TyperLogLevel[TyperLogLevel["WARNING"] = 4] = "WARNING";
TyperLogLevel[TyperLogLevel["NOTICE"] = 5] = "NOTICE";
TyperLogLevel[TyperLogLevel["INFORMATIONAL"] = 6] = "INFORMATIONAL";
TyperLogLevel[TyperLogLevel["DEBUG"] = 7] = "DEBUG";
})(TyperLog.TyperLogLevel || (TyperLog.TyperLogLevel = {}));
var TyperLogLevel = TyperLog.TyperLogLevel;
})(TyperLog || (TyperLog = {}));
//# sourceMappingURL=typerlog.js.map

1
build/typerlog.js.map Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"typerlog.js","sourceRoot":"","sources":["../lib/TyperLog/TyperLog.ts","../lib/TyperLog/TyperLogLevel.ts"],"names":["TyperLog","TyperLog.TyperLog","TyperLog.TyperLog.constructor","TyperLog.TyperLog.Log","TyperLog.TyperLogLevel"],"mappings":"AAAA,IAAO,QAAQ;AA6Bd,CA7BD,UAAO,SAAQ;IACXA;QAAAC;QA2BAC,CAACA;AAAAD,QARGA,eAAAA,UAAkBA,OAAcA,EAAEA,KAAmBA,EAAEA,QAAoBA;YAApBE,uCAAAA,QAAQA,GAAUA,EAAEA;AAAAA,YACvEA,IAAIA,KAAKA,IAAIA,IAAIA,CAACA,QAAQA,CAAEA;gBACxBA,QAAQA,CAACA,OAAOA,CAACA,KAAKA,CAACA,CAACA,OAAOA,CAACA;aACnCA;QAELA,CAACA;QAvBDF,oBAAwCA,eAAqBA;QAC7DA,mBAAyBA,CAACA;YACtBA,IAAIA,IAAIA,GAAGA;YAAKA,CAACA;YACjBA,IAAIA,OAAOA,GAAMA,MAAMA,CAACA,OAAOA,IAAIA,EAAEA;YACrCA,OAAOA,CAACA,KAAKA,CAACA,GAAGA,MAAMA,CAACA,OAAOA,CAACA,GAAGA,IAAIA,IAAIA;YAC3CA,OAAOA,CAACA,OAAOA,CAACA,GAAGA;gBACfA,IAAIA;oBAEAA,MAAMA,EAAEA;iBACXA,CAACA,OAAMA,CAACA,CAAEA;oBACPA,OAAOA,CAACA,KAAKA,CAACA,CAACA,CAACA,CAACA,KAAKA,CAACA;iBAC1BA;YACLA,CAACA;YACDA,OAAOA,CAACA,OAAOA,CAACA,GAAGA,MAAMA,CAACA,OAAOA,CAACA,KAAKA,IAAIA,IAAIA;;YAE/CA,OAAOA,OAAOA;QAClBA,CAACA,CAACA,CAACA,CAACA;QAURA,gBAACA;IAADA,CAACA,IAAAD;IA3BDA,8BA2BCA;AACLA,CAACA,+BAAA;AC7BD,IAAO,QAAQ;AAWd,CAXD,UAAO,QAAQ;KACXA,UAAYA,aAAaA;QACrBI,2DAASA;QACTA,mDAAKA;QACLA,yDAAQA;QACRA,mDAAKA;QACLA,uDAAOA;QACPA,qDAAMA;QACNA,mEAAaA;QACbA,mDAAKA;gEACRJ;+CAAAA;AACLA,CAACA,+BAAA"}

2
build/typerlog.min.js vendored Normal file
View file

@ -0,0 +1,2 @@
var TyperLog;!function(a){var b=function(){function a(){}return a.Log=function(b,c,d){"undefined"==typeof d&&(d=""),c<=this.logLevel&&a.console.log(b)},a.logLevel=4,a.console=function(){var a=function(){},b=window.console||{};return b.log=window.console.log||a,b.trace=function(){try{throw{}}catch(a){b.log(a.trace)}},b.debug=window.console.debug||a,b}(),a}();a.TyperLog=b}(TyperLog||(TyperLog={}));var TyperLog;!function(a){!function(a){a[a.EMERGENCY=0]="EMERGENCY",a[a.ALERT=1]="ALERT",a[a.CRITICAL=2]="CRITICAL",a[a.ERROR=3]="ERROR",a[a.WARNING=4]="WARNING",a[a.NOTICE=5]="NOTICE",a[a.INFORMATIONAL=6]="INFORMATIONAL",a[a.DEBUG=7]="DEBUG"}(a.TyperLogLevel||(a.TyperLogLevel={}));a.TyperLogLevel}(TyperLog||(TyperLog={}));
//# sourceMappingURL=typerlog.min.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"typerlog.min.js","sources":["typerlog.js"],"names":["TyperLog","_TyperLog","Log","message","level","category","this","logLevel","console","noop","window","log","e","trace","debug","TyperLogLevel"],"mappings":"AAAA,GAAIA,WACJ,SAAWC,GACP,GAAID,GAAW,WACX,QAASA,MAyBT,MAvBAA,GAASE,IAAM,SAAUC,EAASC,EAAOC,GACb,mBAAbA,KAA4BA,EAAW,IAC9CD,GAASE,KAAKC,UACdP,EAASQ,QAAa,IAAEL,IAGhCH,EAASO,SAAW,EACpBP,EAASQ,QAAU,WACf,GAAIC,GAAO,aAEPD,EAAUE,OAAOF,WAWrB,OAVAA,GAAa,IAAIE,OAAOF,QAAQG,KAAOF,EACvCD,EAAe,MAAI,WACf,IACI,QACF,MAAOI,GACLJ,EAAa,IAAEI,EAAEC,SAGzBL,EAAe,MAAIE,OAAOF,QAAQM,OAASL,EAEpCD,KAEJR,IAEXC,GAAUD,SAAWA,GACtBA,WAAaA,aAChB,IAAIA,WACJ,SAAWA,IACP,SAAWe,GACPA,EAAcA,EAAyB,UAAI,GAAK,YAChDA,EAAcA,EAAqB,MAAI,GAAK,QAC5CA,EAAcA,EAAwB,SAAI,GAAK,WAC/CA,EAAcA,EAAqB,MAAI,GAAK,QAC5CA,EAAcA,EAAuB,QAAI,GAAK,UAC9CA,EAAcA,EAAsB,OAAI,GAAK,SAC7CA,EAAcA,EAA6B,cAAI,GAAK,gBACpDA,EAAcA,EAAqB,MAAI,GAAK,SAC7Cf,EAASe,gBAAkBf,EAASe,kBACnBf,GAASe,eAC9Bf,WAAaA","sourcesContent":["var TyperLog;\n(function (_TyperLog) {\n var TyperLog = (function () {\n function TyperLog() {\n }\n TyperLog.Log = function (message, level, category) {\n if (typeof category === \"undefined\") { category = \"\"; }\n if (level <= this.logLevel) {\n TyperLog.console[\"log\"](message);\n }\n };\n TyperLog.logLevel = 4 /* WARNING */;\n TyperLog.console = (function () {\n var noop = function () {\n };\n var console = window.console || {};\n console[\"log\"] = window.console.log || noop;\n console[\"trace\"] = function () {\n try {\n throw {};\n } catch (e) {\n console[\"log\"](e.trace);\n }\n };\n console[\"debug\"] = window.console.debug || noop;\n\n return console;\n })();\n return TyperLog;\n })();\n _TyperLog.TyperLog = TyperLog;\n})(TyperLog || (TyperLog = {}));\nvar TyperLog;\n(function (TyperLog) {\n (function (TyperLogLevel) {\n TyperLogLevel[TyperLogLevel[\"EMERGENCY\"] = 0] = \"EMERGENCY\";\n TyperLogLevel[TyperLogLevel[\"ALERT\"] = 1] = \"ALERT\";\n TyperLogLevel[TyperLogLevel[\"CRITICAL\"] = 2] = \"CRITICAL\";\n TyperLogLevel[TyperLogLevel[\"ERROR\"] = 3] = \"ERROR\";\n TyperLogLevel[TyperLogLevel[\"WARNING\"] = 4] = \"WARNING\";\n TyperLogLevel[TyperLogLevel[\"NOTICE\"] = 5] = \"NOTICE\";\n TyperLogLevel[TyperLogLevel[\"INFORMATIONAL\"] = 6] = \"INFORMATIONAL\";\n TyperLogLevel[TyperLogLevel[\"DEBUG\"] = 7] = \"DEBUG\";\n })(TyperLog.TyperLogLevel || (TyperLog.TyperLogLevel = {}));\n var TyperLogLevel = TyperLog.TyperLogLevel;\n})(TyperLog || (TyperLog = {}));\n//# sourceMappingURL=typerlog.js.map\n"]}

23
karma.conf.js Normal file
View file

@ -0,0 +1,23 @@
module.exports = function(config) {
var pkg = require('./package.json');
config.set({
sauceLabs: {
startConnect: true,
testName: 'TypertextTests',
recordScreenshots: false
},
basePath: __dirname,
frameworks: ['jasmine'],
files: [
'test/**/*.js',
pkg.build.directory + "/" + pkg.build.baseArtifact + ".js"
],
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher',
'karma-sauce-launcher',
'karma-chrome-launcher'
]
});
};

30
lib/TyperLog/TyperLog.ts Normal file
View file

@ -0,0 +1,30 @@
module TyperLog {
export class TyperLog {
private static logLevel:TyperLogLevel = TyperLogLevel.WARNING;
private static console = (()=>{
var noop = ()=>{};
var console:{} = window.console || {};
console["log"] = window.console.log || noop;
console["trace"] = ()=> {
try {
//noinspection ExceptionCaughtLocallyJS
throw {};
} catch(e) {
console["log"](e.trace);
}
};
console["debug"] = window.console.debug || noop;
return console;
})();
public static Log(message:string, level:TyperLogLevel, category:string = "") {
if (level <= this.logLevel) {
TyperLog.console["log"](message);
}
}
private static
}
}

View file

@ -0,0 +1,12 @@
module TyperLog {
export enum TyperLogLevel {
EMERGENCY,
ALERT,
CRITICAL,
ERROR,
WARNING,
NOTICE,
INFORMATIONAL,
DEBUG
}
}

36
package.json Normal file
View file

@ -0,0 +1,36 @@
{
"name": "TyperLog",
"description": "A simple TypeScript logging framework",
"repository": {
"type": "git",
"url": "https://github.com/terribleplan/TyperLog"
},
"version": "0.0.1",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-cli": "~0.1.13",
"grunt-contrib-uglify": "~0.3.2",
"grunt-karma": "~0.6.2",
"grunt-typescript": "~0.2.7",
"karma": "~0.10.9",
"karma-chrome-launcher": "~0.1.2",
"karma-coffee-preprocessor": "~0.1.3",
"karma-firefox-launcher": "~0.1.3",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.5",
"karma-requirejs": "~0.2.1",
"karma-sauce-launcher": "~0.1.8",
"karma-script-launcher": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.2",
"phantomjs": "~1.9.7-1",
"requirejs": "~2.1.11"
},
"license": "MIT",
"scripts": {
"test": "./node_modules/.bin/grunt test:travis"
},
"build": {
"directory": "build",
"baseArtifact": "typerlog"
}
}

View file

@ -0,0 +1,5 @@
describe("TyperLog.TyperLog", function() {
it("exists", function() {
expect(typeof TyperLog.TyperLog).toEqual("function");
});
});