Created
November 8, 2017 10:09
-
-
Save misato/d0dc26b596ac12325ea4cd15c8fe85eb to your computer and use it in GitHub Desktop.
Debug utilities for Fitbit Ionic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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