Skip to content

Commit

Permalink
make registerLogger private
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Dec 5, 2019
1 parent 17d8c3f commit ce03272
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion modules/core/bundle/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
import {getLoggers} from '../src/debug/loggers';

const loggers = getLoggers(deck.log);
deck.registerLoggers(loggers);
deck._registerLoggers(loggers);
14 changes: 8 additions & 6 deletions modules/core/src/debug/loggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ export const getLoggers = log => ({
/* Layer events */

'layer.changeFlag': (layer, key, flags) => {
let value = flags[key];
if (key === 'updateTriggersChanged') {
value = Object.keys(value).join(', ');
}
log.log(PRIORITY_UPDATE_DETAIL, `${key}: ${value} in ${layer.id}`)();
log.log(PRIORITY_UPDATE_DETAIL, `${layer.id} ${key}: `, flags[key])();
},

'layer.initialize': layer => {
log.log(PRIORITY_MAJOR_UPDATE, `Initializing ${layer}`)();
},
'layer.update': (layer, needsUpdate) => {
if (needsUpdate) {
log.log(PRIORITY_MINOR_UPDATE, `Updating ${layer} because: ${layer.printChangeFlags()}`)();
const flags = layer.getChangeFlags();
log.log(
PRIORITY_MINOR_UPDATE,
`Updating ${layer} because: ${Object.keys(flags)
.filter(key => flags[key])
.join(', ')}`
)();
} else {
log.log(PRIORITY_INFO, `${layer} does not need update`)();
}
Expand Down
5 changes: 3 additions & 2 deletions modules/core/src/lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {ImageLoader} from '@loaders.gl/images';

import {global} from '../utils/globals';
import log from '../utils/log';
import {register as registerLoggers} from '../debug';
import {register} from '../debug';
import jsonLoader from '../utils/json-loader';

// Version detection using babel plugin
Expand All @@ -46,7 +46,8 @@ if (!global.deck) {
VERSION: version,
version,
log,
registerLoggers
// experimental
_registerLoggers: register
};

registerLoaders([jsonLoader, ImageLoader]);
Expand Down
10 changes: 0 additions & 10 deletions modules/core/src/lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,16 +743,6 @@ export default class Layer extends Component {
};
}

printChangeFlags() {
const flags = this.internalState.changeFlags;
return `\
${flags.dataChanged ? 'data ' : ''}\
${flags.propsChanged ? 'props ' : ''}\
${flags.updateTriggersChanged ? 'triggers ' : ''}\
${flags.viewportChanged ? 'viewport' : ''}\
`;
}

// Compares the layers props with old props from a matched older layer
// and extracts change flags that describe what has change so that state
// can be update correctly with minimal effort
Expand Down

0 comments on commit ce03272

Please sign in to comment.