Skip to content

Commit f5ad492

Browse files
committed
Do @firebase/database integration
1 parent 4e59a63 commit f5ad492

File tree

4 files changed

+12
-29
lines changed

4 files changed

+12
-29
lines changed

packages/database/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@firebase/database-types": "0.1.1",
23+
"@firebase/logger": "0.1.0",
2324
"@firebase/util": "0.1.7",
2425
"faye-websocket": "0.11.1"
2526
},

packages/database/src/core/PersistentConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,8 @@ export class PersistentConnection extends ServerActions {
935935
if (this.securityDebugCallback_) {
936936
this.securityDebugCallback_(body);
937937
} else {
938-
if ('msg' in body && typeof console !== 'undefined') {
939-
console.log('FIREBASE: ' + body['msg'].replace('\n', '\nFIREBASE: '));
938+
if ('msg' in body) {
939+
log('FIREBASE: ' + body['msg'].replace('\n', '\nFIREBASE: '));
940940
}
941941
}
942942
}

packages/database/src/core/Repo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ export class Repo {
653653
forEach(stats, (stat: string, value: any) => {
654654
// pad stat names to be the same length (plus 2 extra spaces).
655655
for (let i = stat.length; i < longestName + 2; i++) stat += ' ';
656-
console.log(stat + value);
656+
log(stat + value);
657657
});
658658
}
659659

packages/database/src/core/util/util.ts

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import { stringToByteArray } from '@firebase/util';
2727
import { stringify } from '@firebase/util';
2828
import { SessionStorage } from '../storage/storage';
2929
import { isNodeSdk } from '@firebase/util';
30+
import { Logger } from "@firebase/logger";
31+
32+
const logClient = new Logger();
3033

3134
/**
3235
* Returns a locally-unique ID (generated by just incrementing up from 0 each time its called).
@@ -105,16 +108,7 @@ export const enableLogging = function(
105108
"Can't turn on custom loggers persistently."
106109
);
107110
if (logger_ === true) {
108-
if (typeof console !== 'undefined') {
109-
if (typeof console.log === 'function') {
110-
logger = console.log.bind(console);
111-
} else if (typeof console.log === 'object') {
112-
// IE does this.
113-
logger = function(message) {
114-
console.log(message);
115-
};
116-
}
117-
}
111+
logger = logClient.log.bind(logClient);
118112
if (persistent) SessionStorage.set('logging_enabled', true);
119113
} else if (typeof logger_ === 'function') {
120114
logger = logger_;
@@ -157,14 +151,8 @@ export const logWrapper = function(
157151
* @param {...string} var_args
158152
*/
159153
export const error = function(...var_args: string[]) {
160-
if (typeof console !== 'undefined') {
161-
const message = 'FIREBASE INTERNAL ERROR: ' + buildLogMessage_(...var_args);
162-
if (typeof console.error !== 'undefined') {
163-
console.error(message);
164-
} else {
165-
console.log(message);
166-
}
167-
}
154+
const message = 'FIREBASE INTERNAL ERROR: ' + buildLogMessage_(...var_args);
155+
logClient.error(message);
168156
};
169157

170158
/**
@@ -179,14 +167,8 @@ export const fatal = function(...var_args: string[]) {
179167
* @param {...*} var_args
180168
*/
181169
export const warn = function(...var_args: any[]) {
182-
if (typeof console !== 'undefined') {
183-
const message = 'FIREBASE WARNING: ' + buildLogMessage_(...var_args);
184-
if (typeof console.warn !== 'undefined') {
185-
console.warn(message);
186-
} else {
187-
console.log(message);
188-
}
189-
}
170+
const message = 'FIREBASE WARNING: ' + buildLogMessage_(...var_args);
171+
logClient.warn(message);
190172
};
191173

192174
/**

0 commit comments

Comments
 (0)