Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	dist/logline.min.js
#	dist/logline.min.js.map
  • Loading branch information
latel committed Sep 7, 2018
2 parents ab07ef7 + c26b3ea commit 793a0e0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
12 changes: 5 additions & 7 deletions dist/logline.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ var Pool = function () {
return Pool;
}();

var READ_WRITE = 'readwrite';

/**
* IndexedDB protocol
* @class IndexedDBLogger
Expand Down Expand Up @@ -485,7 +487,7 @@ var IndexedDBLogger = function (_LoggerInterface) {
}

debug(this._namespace, level, descriptor, data);
var transaction = IndexedDBLogger.db.transaction(['logs'], IDBTransaction.READ_WRITE || 'readwrite');
var transaction = IndexedDBLogger.db.transaction(['logs'], READ_WRITE || 'readwrite');
transaction.onerror = function (event) {
return throwError(event.target.error);
};
Expand Down Expand Up @@ -649,7 +651,7 @@ var IndexedDBLogger = function (_LoggerInterface) {
});
}

var store = IndexedDBLogger._getTransactionStore(IDBTransaction.READ_WRITE);
var store = IndexedDBLogger._getTransactionStore(READ_WRITE);
if (!store) {
return false;
}
Expand Down Expand Up @@ -722,7 +724,7 @@ var IndexedDBLogger = function (_LoggerInterface) {
value: function _getTransactionStore(mode) {
try {
if (IndexedDBLogger.db) {
var transaction = IndexedDBLogger.db.transaction(['logs'], mode || IDBTransaction.READ_WRITE);
var transaction = IndexedDBLogger.db.transaction(['logs'], mode || READ_WRITE);
transaction.onerror = function (event) {
return throwError(event.target.error);
};
Expand All @@ -745,10 +747,6 @@ var IndexedDBLogger = function (_LoggerInterface) {
key: 'support',
get: function get$$1() {
var support = !!(window.indexedDB && window.IDBTransaction && window.IDBKeyRange);
if (support) {
window.IDBTransaction.READ_WRITE = 'readwrite';
window.IDBTransaction.READ_ONLY = 'readonly';
}
return support;
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion dist/logline.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/logline.min.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logline",
"version": "1.1.1",
"version": "1.1.2",
"description": "logs for the frontend",
"main": "dist/logline.min.js",
"scripts": {
Expand Down Expand Up @@ -31,6 +31,7 @@
"homepage": "https://github.com/latel/logline#readme",
"devDependencies": {
"babel-core": "^6.7.7",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-env": "^1.7.0",
"chai": "^3.5.0",
Expand All @@ -42,11 +43,13 @@
"gulp-compile-handlebars": "^0.6.1",
"gulp-rename": "^1.2.2",
"html-loader": "^0.4.3",
"install": "^0.12.1",
"jsonfile": "^2.4.0",
"minimist": "^1.2.0",
"mocha": "^2.5.3",
"mocha-headless-chrome": "1.7.1",
"moment": "^2.13.0",
"npm": "^6.4.1",
"rollup": "^0.41.4",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-license": "^0.2.0",
Expand Down
12 changes: 5 additions & 7 deletions src/protocols/indexeddb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import LoggerInterface from './interface';
import Pool from '../lib/pool';
import * as util from '../lib/util';

const READ_WRITE = 'readwrite';

/**
* IndexedDB protocol
* @class IndexedDBLogger
Expand Down Expand Up @@ -35,7 +37,7 @@ export default class IndexedDBLogger extends LoggerInterface {
}

util.debug(this._namespace, level, descriptor, data);
let transaction = IndexedDBLogger.db.transaction(['logs'], IDBTransaction.READ_WRITE || 'readwrite');
let transaction = IndexedDBLogger.db.transaction(['logs'], READ_WRITE || 'readwrite');
transaction.onerror = event => util.throwError(event.target.error);

let store = transaction.objectStore('logs');
Expand Down Expand Up @@ -176,7 +178,7 @@ export default class IndexedDBLogger extends LoggerInterface {
return IndexedDBLogger._pool.push(() => IndexedDBLogger.keep(daysToMaintain));
}

let store = IndexedDBLogger._getTransactionStore(IDBTransaction.READ_WRITE);
let store = IndexedDBLogger._getTransactionStore(READ_WRITE);
if (!store) {
return false;
}
Expand Down Expand Up @@ -236,7 +238,7 @@ export default class IndexedDBLogger extends LoggerInterface {
static _getTransactionStore(mode) {
try {
if (IndexedDBLogger.db) {
let transaction = IndexedDBLogger.db.transaction(['logs'], mode || IDBTransaction.READ_WRITE);
let transaction = IndexedDBLogger.db.transaction(['logs'], mode || READ_WRITE);
transaction.onerror = event => util.throwError(event.target.error);
return transaction.objectStore('logs');
}
Expand All @@ -255,10 +257,6 @@ export default class IndexedDBLogger extends LoggerInterface {
*/
static get support() {
const support = !!(window.indexedDB && window.IDBTransaction && window.IDBKeyRange);
if (support) {
window.IDBTransaction.READ_WRITE = 'readwrite';
window.IDBTransaction.READ_ONLY = 'readonly';
}
return support;
}
}
27 changes: 16 additions & 11 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Logline.config({
});

var readyTimer, repeated, isReady = function(readyFn) {
clearInterval(readyTimer), repeated = 0;
clearInterval(readyTimer);
repeated = 0;
readyTimer = setInterval(function() {
var ready = 0, i;
if (repeated++ > 20) {
Expand Down Expand Up @@ -58,23 +59,27 @@ describe('Logline', function() {

it('should be able to specialfy any available protocols', function(done) {
for (var i = 0; i < Object.keys(window.Logline.PROTOCOL).length; i++) {
window.Logline.using(window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]]);
assert.equal(window.Logline._protocol, window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]], 'protocol should be properly setted');
window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]].clean();
delete window.Logline._protocol;
if (window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]].support) {
window.Logline.using(window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]]);
assert.equal(window.Logline._protocol, window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]], 'protocol should be properly setted');
window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]].clean();
delete window.Logline._protocol;
}
}
done();
});

it('should be able to create any available protocols instance', function(done) {
isReady(function() {
for (var i = 0; i < Object.keys(window.Logline.PROTOCOL).length; i++) {
window.Logline.using(window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]]);
var logger = new window.Logline('a');
assert.equal(window.Logline._protocol, window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]], 'protocol should be properly setted');
assert.instanceOf(logger, window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]], 'log instance should be correctly created');
window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]].clean();
delete window.Logline._protocol;
if (window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]].support) {
window.Logline.using(window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]]);
var logger = new window.Logline('a');
assert.equal(window.Logline._protocol, window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]], 'protocol should be properly setted');
assert.instanceOf(logger, window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]], 'log instance should be correctly created');
window.Logline.PROTOCOL[Object.keys(window.Logline.PROTOCOL)[i]].clean();
delete window.Logline._protocol;
}
}
done();
});
Expand Down

0 comments on commit 793a0e0

Please sign in to comment.