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

cordova-plugin-secure-logger

v1.4.17

Published

cordova plugin for securely writing logs to local app cache

Downloads

23

Readme

cordova-plugin-secure-logger

Cordova plugin to capture both webview and native log events and store them securely on disk.

Also works out-the-box with Capacitor!

Features / Goals

  • Ability to capture logs both from the webview and native side into a common local recording outlet
  • Encrypt data before it hits the disk to protect sensitive user data
  • Automatically prune oldest logs to prevent infinitely expanding log data storage
  • Ability to load logs from disk, combined and unencrypted, so they can be uploaded to a server as needed

Why make this plugin?

The most secure solution when dealing with sensitive user data is to not log anything at all.

However, when it comes to tracking down nefarious bugs that only happen in the field, the next best thing is to capture logs in a secure sandbox - which is the aim of this plugin.

Installation

Github:

npm i -P -E git+https://github.com/jospete/cordova-plugin-secure-logger.git#1.4.17

NPM / Capacitor:

npm i -P -E cordova-plugin-secure-logger

Cordova:

cordova plugin add cordova-plugin-secure-logger

Usage

Documentation

Source documentation can be found here

Plugin Initialization

/* In your app initialize logic */
import { SecureLogger, SecureLogLevel, enableWebviewListener } from 'cordova-plugin-secure-logger';

// Wire up the primary rx-console transport with secure logger webview proxy.
enableWebviewListener();

// after platform ready event
await SecureLogger.configure({
    minLevel: SecureLogLevel.DEBUG,
    // See documentation for other available options
});

Logging Events

You can produce logs for this plugin on both the webview and native side

TypeScript / JavaScript (webview)

This plugin uses @obsidize/rx-console for webview log capture / filtering. See rx-console docs for proper usage of this module.

import { Logger } from '@obsidize/rx-console';

const logger = new Logger('ExampleService');

// Log events from rx-console will automatically get buffered and 
// sent to the plugin on a fixed interval.
logger.debug(`This will be stored in an encrypted log file`);

const someError = {error: `transfunctioner stopped combobulating`};
logger.warn(`Something bad happened! ->`, someError);

Android:

This plugin uses Timber for Android native log capture. Replace Log.xxx() calls from android.util.Log with Timber.xxx() from timber.log.Timber in other plugins, and those logs will automatically be captured by this plugin.

In plugin.xml:

<platform name="android">
    ...
    <framework src="com.jakewharton.timber:timber:5.0.1" />
</platform>

In Kotlin / Java:

import timber.log.Timber

...

Timber.d("Logging stuff on native android for the secure logger plugin! Yay native logs!")

iOS:

This plugin uses CocoaLumberjack for iOS native log capture. Replace print() / NSLog() calls with DDLogXXXX() in other plugins, and those logs will automatically be captured by this plugin.

In plugin.xml:

<platform name="ios">
    ...
    <podspec>
        <config>
            <source url="https://cdn.cocoapods.org/" />
        </config>
        <pods use-frameworks="true">
            <pod name="CocoaLumberjack/Swift" spec="~> 3.8" />
        </pods>
    </podspec>
</platform>

In Swift:

import CocoaLumberjack

...

DDLogDebug("Logging stuff on native ios for the secure logger plugin! Yay native logs!")

In Objective-C:

#import <CocoaLumberjack/CocoaLumberjack.h>
#define ddLogLevel DDLogLevelAll

...

DDLogDebug("Logging stuff on native ios for the secure logger plugin! Yay native logs!");

Gathering Logs to Report

To grab a snapshot of the current log cache:

import { SecureLogger } from 'cordova-plugin-secure-logger';

async function uploadLogs(): Promise<void> {
    const logCacheData = await SecureLogger.getCacheBlob();
    const bodyBlob = new Blob([logCacheData], { type: 'application/octet-stream' });
    // upload / share it somewhere
    await http.post('/log-capture', bodyBlob);
}

Examples