Skip to content

Commit

Permalink
Merge branch 'feature/async-logger' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lkan committed Jul 27, 2014
2 parents 4b01933 + bc42725 commit faf9322
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 24 deletions.
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,4 +1,3 @@
language: node_js
node_js:
- "0.10"
- "0.8"
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
# o2.js v.2.1.0

* Created a debugger that does async logging on the server, and logs to the console on the client.
* Slightly changed the dependency mechanism between modules.

# o2.js v.2.0.7

* Added minimally working **timer**, **object**, and **validate** modules.
Expand Down
2 changes: 1 addition & 1 deletion amd/o2/ajax/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.ajax",
"version": "0.0.9",
"version": "0.0.11",
"description": "o2.js AJAX Helpers",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
4 changes: 4 additions & 0 deletions amd/o2/debug/CHANGELOG.md
@@ -1,3 +1,7 @@
# o2.debug@0.1.0

* Created a very basic async logger.

# o2.debug@0.0.0

* Initial commit.
66 changes: 60 additions & 6 deletions amd/o2/debug/core.js
Expand Up @@ -7,19 +7,73 @@ define(function (require, exports, module) {'use strict';
* Please see the LICENSE.md file for details.
*/

var isConsoleAvailable = (typeof console !== 'undefined');
var isNode = (typeof module !== 'undefined' && !!module.exports),
isConsoleAvailable = (typeof console !== 'undefined'),

kFs = 'fs',

stream;

function print(label, args) {
var buffer = [],
i, len;

for (i = 0, len = args.length; i < len; i++) {
buffer.push(args[i]);
}

stream.write(label + ': ' + buffer.join(','));
}

if (isNode) {
exports.initialize = function(file) {

// To trick grunt-contrib-jasmine.
var fs = require(kFs);

if (typeof file === 'string') {
stream = fs.createFileStream(
file, {flags: 'a+', encoding: 'utf8'}
);

return;
}

stream = file;
};

if (isConsoleAvailable) {
exports.log = function() {
console.log.apply(console, arguments);
if (!stream) {
throw new Error(
'o2.debug: Please call `o2.debug.initialize` first.'
);
}

print('[LOG ]', arguments);
};

exports.warn = function() {
console.warn.apply(console, arguments);
if (!stream) {
throw new Error(
'o2.debug: Please call `o2.debug.initialize` first.'
);
}

print('[WARN]', arguments);
};
} else {
exports.log = function() {};
exports.warn = function() {};
if (isConsoleAvailable) {
exports.log = function() {
console.log.apply(console, arguments);
};

exports.warn = function() {
console.warn.apply(console, arguments);
};
} else {
exports.log = function() {};
exports.warn = function() {};
}
}

});
2 changes: 1 addition & 1 deletion amd/o2/debug/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.debug",
"version": "0.0.3",
"version": "0.1.0",
"description": "o2.js console helper",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion amd/o2/functional/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.functional",
"version": "0.0.0",
"version": "0.0.2",
"description": "o2.js Functional Programming Utility Methods",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion amd/o2/io/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.io",
"version": "0.0.1",
"version": "0.0.3",
"description": "o2.js FileSystem-related methods",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion amd/o2/object/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.object",
"version": "0.0.7",
"version": "0.0.9",
"description": "o2.js object-related methods",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion amd/o2/string/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.string",
"version": "0.0.9",
"version": "0.0.11",
"description": "o2.js String utility methods",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion amd/o2/then/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.then",
"version": "0.2.0",
"version": "0.2.4",
"description": "o2.js Deferred Helpers - A Promises/A+ Compliant Deferred Library",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion amd/o2/timer/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.timer",
"version": "0.0.8",
"version": "0.0.9",
"description": "o2.js timer utility methods",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion amd/o2/validation/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.validation",
"version": "0.2.0",
"version": "0.2.2",
"description": "o2.js validation-related methods",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "o2",
"version": "2.0.12",
"version": "2.1.0",
"author": "Volkan Özçelik <me@volkan.io>",
"description": "o2.js JavaScript Framework",
"homepage": "http://o2js.com/",
Expand Down
4 changes: 4 additions & 0 deletions src/o2/debug/CHANGELOG.md
@@ -1,3 +1,7 @@
# o2.debug@0.1.0

* Created a very basic async logger.

# o2.debug@0.0.0

* Initial commit.
66 changes: 60 additions & 6 deletions src/o2/debug/core.js
Expand Up @@ -7,17 +7,71 @@
* Please see the LICENSE.md file for details.
*/

var isConsoleAvailable = (typeof console !== 'undefined');
var isNode = (typeof module !== 'undefined' && !!module.exports),
isConsoleAvailable = (typeof console !== 'undefined'),

kFs = 'fs',

stream;

function print(label, args) {
var buffer = [],
i, len;

for (i = 0, len = args.length; i < len; i++) {
buffer.push(args[i]);
}

stream.write(label + ': ' + buffer.join(','));
}

if (isNode) {
exports.initialize = function(file) {

// To trick grunt-contrib-jasmine.
var fs = require(kFs);

if (typeof file === 'string') {
stream = fs.createFileStream(
file, {flags: 'a+', encoding: 'utf8'}
);

return;
}

stream = file;
};

if (isConsoleAvailable) {
exports.log = function() {
console.log.apply(console, arguments);
if (!stream) {
throw new Error(
'o2.debug: Please call `o2.debug.initialize` first.'
);
}

print('[LOG ]', arguments);
};

exports.warn = function() {
console.warn.apply(console, arguments);
if (!stream) {
throw new Error(
'o2.debug: Please call `o2.debug.initialize` first.'
);
}

print('[WARN]', arguments);
};
} else {
exports.log = function() {};
exports.warn = function() {};
if (isConsoleAvailable) {
exports.log = function() {
console.log.apply(console, arguments);
};

exports.warn = function() {
console.warn.apply(console, arguments);
};
} else {
exports.log = function() {};
exports.warn = function() {};
}
}
2 changes: 1 addition & 1 deletion src/o2/debug/package.json
@@ -1,6 +1,6 @@
{
"name": "o2.debug",
"version": "0.0.5",
"version": "0.1.0",
"description": "o2.js console helper",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit faf9322

Please sign in to comment.