-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(*): set up the project structure and build
This commit adds the initial source code, sets up the project structure, creates the gulp build file and configures karma.
- Loading branch information
1 parent
cf20f72
commit e9e5839
Showing
15 changed files
with
761 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
# 2 space indentation | ||
[**.*] | ||
indent_style = space | ||
indent_size = 2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
jspm_packages | ||
bower_components | ||
.idea | ||
.DS_STORE |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
jspm_packages | ||
bower_components | ||
.idea |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,67 @@ | ||
logging | ||
======= | ||
# aurelia-logging | ||
|
||
A minimal but effective logging mechanism with support for log levels and pluggable log appenders. | ||
This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains a minimal but effective logging mechanism with support for log levels and pluggable log appenders. | ||
|
||
> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.durandal.io/). If you have questions, we invite you to join us on [our Gitter Channel](https://gitter.im/Aurelia/Discuss). | ||
## Dependencies | ||
|
||
This library has **NO** external dependencies. | ||
|
||
## Platform Support | ||
|
||
This library can be used in the **browser** as well as on the **server**. | ||
|
||
## Building The Code | ||
|
||
To build the code, follow these steps. | ||
|
||
1. Ensure that [NodeJS](http://nodejs.org/) is installed. This provides the platform on which the build tooling runs. | ||
2. From the project folder, execute the following command: | ||
|
||
```shell | ||
npm install | ||
``` | ||
3. Ensure that [Gulp](http://gulpjs.com/) is installed. If you need to install it, use the following command: | ||
|
||
```shell | ||
npm install -g gulp | ||
``` | ||
4. To build the code, you can now run: | ||
|
||
```shell | ||
gulp build | ||
``` | ||
5. You will find the compiled code in the `dist` folder, available in three module formats: AMD, CommonJS and ES6. | ||
|
||
6. See `gulpfile.js` for other tasks related to generating the docs and linting. | ||
|
||
## Running The Tests | ||
|
||
To run the unit tests, first ensure that you have followed the steps above in order to install all dependencies and successfully build the library. Once you have done that, proceed with these additional steps: | ||
|
||
1. Ensure that the [Karma](http://karma-runner.github.io/) CLI is installed. If you need to install it, use the following command: | ||
|
||
```shell | ||
npm install -g karma-cli | ||
``` | ||
2. Ensure that [jspm](http://jspm.io/) is installed. If you need to install it, use the following commnand: | ||
|
||
```shell | ||
npm install -g jspm | ||
``` | ||
3. Download the [SystemJS](https://github.com/systemjs/systemjs) module loader: | ||
|
||
```shell | ||
jspm dl-loader | ||
``` | ||
|
||
4. You can now run the tests with this command: | ||
|
||
```shell | ||
karma start | ||
``` | ||
|
||
## Contributing | ||
|
||
We'd love for you to contribute to our source code and to make this project even better than it is today! If this interests you, please begin by reading [our contributing guidelines](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). The contributing document will provide you with all the information you need to get started. Once you have read that, you will need to also [sign our CLA](http://goo.gl/forms/dI8QDDSyKR) before we can accepts a Pull Request from you. More information on the process is including in the [contributor's guide](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
System.config({ | ||
"paths": { | ||
"*": "*.js" | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
define(["exports"], function (exports) { | ||
"use strict"; | ||
|
||
exports.getLogger = getLogger; | ||
exports.addAppender = addAppender; | ||
exports.setLevel = setLevel; | ||
var loggers = {}, logLevel = 0, appenders = [], slice = Array.prototype.slice, loggerConstructionKey = {}; | ||
|
||
function log(logger, level, args) { | ||
var i = appenders.length, current; | ||
|
||
args = slice.call(args); | ||
args.unshift(logger); | ||
|
||
while (i--) { | ||
current = appenders[i]; | ||
current[level].apply(current, args); | ||
} | ||
} | ||
|
||
function debug() { | ||
if (logLevel < 4) { | ||
return; | ||
} | ||
|
||
log(this, "debug", arguments); | ||
} | ||
|
||
function info() { | ||
if (logLevel < 3) { | ||
return; | ||
} | ||
|
||
log(this, "info", arguments); | ||
} | ||
|
||
function warn() { | ||
if (logLevel < 2) { | ||
return; | ||
} | ||
|
||
log(this, "warn", arguments); | ||
} | ||
|
||
function error() { | ||
if (logLevel < 1) { | ||
return; | ||
} | ||
|
||
log(this, "error", arguments); | ||
} | ||
|
||
function connectLogger(logger) { | ||
logger.debug = debug; | ||
logger.info = info; | ||
logger.warn = warn; | ||
logger.error = error; | ||
} | ||
|
||
function createLogger(id) { | ||
var logger = new Logger(id, loggerConstructionKey); | ||
|
||
if (appenders.length) { | ||
connectLogger(logger); | ||
} | ||
|
||
return logger; | ||
} | ||
|
||
var levels = exports.levels = { | ||
error: 1, | ||
warn: 2, | ||
info: 3, | ||
debug: 4 | ||
}; | ||
|
||
function getLogger(id) { | ||
return loggers[id] || (loggers[id] = createLogger(id)); | ||
} | ||
|
||
function addAppender(appender) { | ||
appenders.push(appender); | ||
|
||
if (appenders.length === 1) { | ||
for (var key in loggers) { | ||
connectLogger(loggers[key]); | ||
} | ||
} | ||
} | ||
|
||
function setLevel(level) { | ||
logLevel = level; | ||
} | ||
|
||
var Logger = (function () { | ||
var Logger = function Logger(id, key) { | ||
if (key !== loggerConstructionKey) { | ||
throw new Error("You cannot instantiate \"Logger\". Use the \"getLogger\" API instead."); | ||
} | ||
|
||
this.id = id; | ||
}; | ||
|
||
Logger.prototype.debug = function () {}; | ||
|
||
Logger.prototype.info = function () {}; | ||
|
||
Logger.prototype.warn = function () {}; | ||
|
||
Logger.prototype.error = function () {}; | ||
|
||
return Logger; | ||
})(); | ||
|
||
exports.Logger = Logger; | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
"use strict"; | ||
|
||
exports.getLogger = getLogger; | ||
exports.addAppender = addAppender; | ||
exports.setLevel = setLevel; | ||
var loggers = {}, logLevel = 0, appenders = [], slice = Array.prototype.slice, loggerConstructionKey = {}; | ||
|
||
function log(logger, level, args) { | ||
var i = appenders.length, current; | ||
|
||
args = slice.call(args); | ||
args.unshift(logger); | ||
|
||
while (i--) { | ||
current = appenders[i]; | ||
current[level].apply(current, args); | ||
} | ||
} | ||
|
||
function debug() { | ||
if (logLevel < 4) { | ||
return; | ||
} | ||
|
||
log(this, "debug", arguments); | ||
} | ||
|
||
function info() { | ||
if (logLevel < 3) { | ||
return; | ||
} | ||
|
||
log(this, "info", arguments); | ||
} | ||
|
||
function warn() { | ||
if (logLevel < 2) { | ||
return; | ||
} | ||
|
||
log(this, "warn", arguments); | ||
} | ||
|
||
function error() { | ||
if (logLevel < 1) { | ||
return; | ||
} | ||
|
||
log(this, "error", arguments); | ||
} | ||
|
||
function connectLogger(logger) { | ||
logger.debug = debug; | ||
logger.info = info; | ||
logger.warn = warn; | ||
logger.error = error; | ||
} | ||
|
||
function createLogger(id) { | ||
var logger = new Logger(id, loggerConstructionKey); | ||
|
||
if (appenders.length) { | ||
connectLogger(logger); | ||
} | ||
|
||
return logger; | ||
} | ||
|
||
var levels = exports.levels = { | ||
error: 1, | ||
warn: 2, | ||
info: 3, | ||
debug: 4 | ||
}; | ||
|
||
function getLogger(id) { | ||
return loggers[id] || (loggers[id] = createLogger(id)); | ||
} | ||
|
||
function addAppender(appender) { | ||
appenders.push(appender); | ||
|
||
if (appenders.length === 1) { | ||
for (var key in loggers) { | ||
connectLogger(loggers[key]); | ||
} | ||
} | ||
} | ||
|
||
function setLevel(level) { | ||
logLevel = level; | ||
} | ||
|
||
var Logger = (function () { | ||
var Logger = function Logger(id, key) { | ||
if (key !== loggerConstructionKey) { | ||
throw new Error("You cannot instantiate \"Logger\". Use the \"getLogger\" API instead."); | ||
} | ||
|
||
this.id = id; | ||
}; | ||
|
||
Logger.prototype.debug = function () {}; | ||
|
||
Logger.prototype.info = function () {}; | ||
|
||
Logger.prototype.warn = function () {}; | ||
|
||
Logger.prototype.error = function () {}; | ||
|
||
return Logger; | ||
})(); | ||
|
||
exports.Logger = Logger; |
Oops, something went wrong.