Skip to content

Instantly share code, notes, and snippets.

@misato
Created November 8, 2017 10:09
Show Gist options
  • Save misato/d0dc26b596ac12325ea4cd15c8fe85eb to your computer and use it in GitHub Desktop.
Save misato/d0dc26b596ac12325ea4cd15c8fe85eb to your computer and use it in GitHub Desktop.
Debug utilities for Fitbit Ionic
import { memory } from "system";
// Debug logs.
// Set `debugEnabled` to false hide debug logs
var debugEnabled = true;
export function log(message) {
if (debugEnabled) {
console.log(message);
}
}
export function showJSMemory() {
log("JS memory: " + memory.js.used + "/" + memory.js.total);
}
// Example of usage of the debug file
import clock from "clock";
import * as debug from "../common/debug";
// Update the clock every minute
clock.granularity = "minutes";
function updateClock() {
let now = new Date();
var hours = now.getHours();
let mins = now.getMinutes();
// if debugEnabled is true, it will show the time and JS memory in the console
debug.log("hour: "+hours+":"+mins);
debug.showJSMemory();
}
clock.ontick = () => updateClock();
updateClock();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment