Skip to content

Commit

Permalink
Added current and previous version information.
Browse files Browse the repository at this point in the history
Closes #614.
  • Loading branch information
imolorhe committed Mar 9, 2019
1 parent 73b44d6 commit a7ac629
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/app/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
import { environment } from 'environments/environment';

const PREVIOUS_VERSION_KEY = 'altair__debug_previous_version';
const CURRENT_VERSION_KEY = 'altair__debug_current_version';
const previousVersion = () => localStorage.getItem(PREVIOUS_VERSION_KEY);
const currentVersion = () => localStorage.getItem(CURRENT_VERSION_KEY);

if (currentVersion() !== environment.version) {
// New app version
// prev = current
// current = env.version
localStorage.setItem(PREVIOUS_VERSION_KEY, currentVersion());
localStorage.setItem(CURRENT_VERSION_KEY, environment.version);
}

Object.defineProperty(window, '__ENABLE_DEBUG_MODE__', {
get() {
return window['_ALTAIR__ENABLE_DEBUG_MODE__'];
},
set(value) {
if (value) {
// Display debug information.
console.group('⚙️🛠Altair Debug Information');
console.log('Previous version:', previousVersion());
console.log('Current version:', currentVersion());
console.groupEnd();
}
window['_ALTAIR__ENABLE_DEBUG_MODE__'] = value;
}
});

/**
* Only logs in development or when __ENABLE_DEBUG_MODE__ flag is true
Expand Down

0 comments on commit a7ac629

Please sign in to comment.