npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fitbit-logger

v0.0.6

Published

Get logs from the device without debugger

Downloads

10

Readme

fitbit-logger

Need to get logs from the device without being attached to a debugger? Either because testing on debugger isn't simulating the exact environment of your users, or because you need to get logs from your users directly?

Enter fitbit-logger.

Fitbit-logger is a replacement for console.log that also persists all the logs to filesystem and sends them to companion. There it can either just log them, so you can see them through Fitbit Android app, or it can post them to an URL of your choice, effectively giving you a way to gather logs from users of your app.

Installation

npm i fitbit-logger

Companion

Create an index.js file in the companion folder if you don't already have one. Add the following code in this file :

import fitlogger from 'fitbit-logger/companion'

options = {
  doConsoleLog: true,
  url: "https://example.com"
}
fitlogger.init(options)

App

Add the following code in your app/index.js file

import fitlogger from 'fitbit-logger/app'

options = {
  doConsoleLog: true,
  automaticInterval: 5000,
  prefix: 'App'
}
fitlogger.init(options)

fitlogger.log("The monkey ate my pajamas")

This particular configuration will result in: being:

  • "The monkey ate my pajamas" logged to console on the app
  • "The monkey ate my pajamas" prefixed with "App" and timestamped and appended to a file on device
  • every 5000 milliseconds, the file will be checked. If it's not empty, it will be queued for transfer to the companion, and cleared
  • on companion, "The monkey ate my pajamas" will be logged to console once the file arrives
  • on companion, a get request will be made to https://example.com?data=App%20123456789%20The%20monkey%20ate%20my%20pajamas

API

Companion

fitlogger.init(options)

Initializes fitbit-logger. Needs to be called first if you want to use the logger.

options object

Options for logger's behavior on the companion.

options.doConsoleLog boolean

False by default. If true, each log from the device will also be logged in companion using console.log, in the following format: App [timestamp] [message]

options.url string

Optional. If any url is set, the companion will post every log to the given url via fetch, whereas the logged message will be encoded as a URL query string.

Example: https://example.com?data=nice%20log

App

fitlogger.init(options)

Initializes fitbit-logger. Needs to be called first if you want to use the logger.

options object

Options for logger's behavior on the device.

options.doConsoleLog boolean

False by default. If true, each log sent via fitlogger.send() will also be logged using console.log() on the device.

options.automaticInterval number

Optional If set to any number larger than 0, sending logs to companion via file-transfer will happen automatically, with an interval of your choice (in ms).

If unset, call fitlogger.sendLogFileToCompanion() to send the logfile manually at your convenience.

options.prefix string

Defaults to 'App' String that will be used as a prefix before each log line

fitlogger.sendLogFileToCompanion()

Trigger sending logfile from device to companion

fitlogger.log(message)

Logs a timestamped message. The message is appended to a file and at some moment sent to companion via file-transfer.

message any

The message to be logged. This can be any data type.

Contribution

I'm not a javascript expert so every comment/code refactoring/best practice and especially BUG REPORTING is appreciated. Don't hesitate to make a PR and/or tell me what's wrong.