Socket
Socket
Sign inDemoInstall

logkitty

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logkitty - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

2

build/android/adb.d.ts
/// <reference types="node" />
import { ChildProcess } from 'child_process';
export declare function runAndroidLoggingProcess(adbPath?: string): ChildProcess;
export declare function runLoggingProcess(adbPath?: string): ChildProcess;
export declare function getAbdPath(customPath?: string): string;

@@ -5,0 +5,0 @@ export declare function spawnLogcatProcess(adbPath: string): ChildProcess;

@@ -6,3 +6,3 @@ "use strict";

});
exports.runAndroidLoggingProcess = runAndroidLoggingProcess;
exports.runLoggingProcess = runLoggingProcess;
exports.getAbdPath = getAbdPath;

@@ -20,3 +20,3 @@ exports.spawnLogcatProcess = spawnLogcatProcess;

function runAndroidLoggingProcess(adbPath) {
function runLoggingProcess(adbPath) {
const execPath = getAbdPath(adbPath);

@@ -38,3 +38,3 @@ return spawnLogcatProcess(execPath);

} catch (error) {
throw new _errors.CodeError(_errors.ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER, error.message);
throw new _errors.CodeError(_errors.ERR_CANNOT_CLEAN_LOGCAT_BUFFER, error.message);
}

@@ -47,3 +47,3 @@

} catch (error) {
throw new _errors.CodeError(_errors.ERR_ANDROID_CANNOT_START_LOGCAT, error.message);
throw new _errors.CodeError(_errors.ERR_CANNOT_START_LOGCAT, error.message);
}

@@ -58,3 +58,3 @@ }

} catch (error) {
throw new _errors.CodeError(_errors.ERR_ANDROID_CANNOT_GET_APP_PID, error.message);
throw new _errors.CodeError(_errors.ERR_CANNOT_GET_APP_PID, error.message);
}

@@ -65,3 +65,3 @@

if (isNaN(pid)) {
throw new _errors.CodeError(_errors.ERR_ANDROID_UNPROCESSABLE_PID);
throw new _errors.CodeError(_errors.ERR_UNPROCESSABLE_PID);
}

@@ -68,0 +68,0 @@

import { IFilter, Entry } from '../types';
export default class AndroidFilter implements IFilter {
export declare class AndroidFilter implements IFilter {
private readonly minPriority;

@@ -4,0 +4,0 @@ private filter;

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = void 0;
exports.AndroidFilter = void 0;

@@ -30,3 +30,3 @@ var _adb = require("./adb");

this.filter = entry => {
return Boolean(entry.priority >= this.minPriority && entry.tag && tags.indexOf(entry.tag) > -1);
return entry.priority >= this.minPriority && tags.indexOf(entry.tag) > -1;
};

@@ -58,3 +58,3 @@ }

this.filter = entry => {
return entry.tag && entry.priority >= (tagFilters[entry.tag] || _constants.Priority.SILENT) || entry.priority >= (tagFilters['*'] || _constants.Priority.UNKNOWN);
return entry.priority >= (tagFilters[entry.tag] || _constants.Priority.SILENT) || entry.priority >= (tagFilters['*'] || _constants.Priority.UNKNOWN);
};

@@ -69,3 +69,3 @@ }

exports.default = AndroidFilter;
exports.AndroidFilter = AndroidFilter;
//# sourceMappingURL=AndroidFilter.js.map

@@ -40,5 +40,5 @@ "use strict";

const [, priority, tag, pid] = headerMatch;
const now = new Date();
return {
platform: 'android',
date: new Date(new Date().getFullYear(), parseInt(timeMatch[1], 10) - 1, parseInt(timeMatch[2], 10) + 1, parseInt(timeMatch[3], 10), parseInt(timeMatch[4], 10), parseInt(timeMatch[5], 10)),
date: new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseInt(timeMatch[1], 10), parseInt(timeMatch[2], 10), parseInt(timeMatch[3], 10)),
pid: parseInt(pid.trim(), 10) || 0,

@@ -63,5 +63,5 @@ priority: _constants.Priority.fromLetter(priority),

_defineProperty(AndroidParser, "timeRegex", /(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}).\d{3}/m);
_defineProperty(AndroidParser, "timeRegex", /\d{2}-\d{2} (\d{2}):(\d{2}):(\d{2}).\d{3}/m);
_defineProperty(AndroidParser, "headerRegex", /^\s*(\w)\/(.+)\(([\s\d]+)\):/);
//# sourceMappingURL=AndroidParser.js.map

@@ -20,3 +20,3 @@ "use strict";

fromName(name) {
const value = codes[name.toUpperCase()];
const value = codes[name];
return value ? value : 0;

@@ -23,0 +23,0 @@ },

/// <reference types="node" />
import { IFilter } from './types';
import { EventEmitter } from 'events';
import { IFilter, Platform } from './types';
export { Priority as AndroidPriority } from './android/constants';
export { Priority as IosPriority } from './ios/constants';
export { formatEntry, formatError } from './formatters';
export { Priority } from './android/constants';
export { Entry } from './types';
export declare type LogkittyOptions = {
platform: Platform;
platform: 'android';
adbPath?: string;

@@ -14,3 +13,3 @@ priority?: number;

};
export declare type FilterCreator = (platform: Platform, minPriority?: number, adbPath?: string) => IFilter;
export declare type FilterCreator = (minPriority?: number, adbPath?: string) => IFilter;
export declare function makeTagsFilter(...tags: string[]): FilterCreator;

@@ -17,0 +16,0 @@ export declare function makeAppFilter(appIdentifier: string): FilterCreator;

@@ -17,63 +17,40 @@ "use strict";

});
Object.defineProperty(exports, "AndroidPriority", {
Object.defineProperty(exports, "formatEntry", {
enumerable: true,
get: function () {
return _constants.Priority;
return _formatters.formatEntry;
}
});
Object.defineProperty(exports, "IosPriority", {
Object.defineProperty(exports, "formatError", {
enumerable: true,
get: function () {
return _constants2.Priority;
return _formatters.formatError;
}
});
Object.defineProperty(exports, "formatEntry", {
Object.defineProperty(exports, "Priority", {
enumerable: true,
get: function () {
return _formatters.formatEntry;
return _constants.Priority;
}
});
Object.defineProperty(exports, "formatError", {
enumerable: true,
get: function () {
return _formatters.formatError;
}
});
var _types = require("./types");
var _events = require("events");
var _types = require("./types");
var _AndroidFilter = require("./android/AndroidFilter");
var _AndroidFilter = _interopRequireDefault(require("./android/AndroidFilter"));
var _adb = require("./android/adb");
var _AndroidParser = _interopRequireDefault(require("./android/AndroidParser"));
var _adb = require("./android/adb");
var _formatters = require("./formatters");
var _constants = require("./android/constants");
var _IosParser = _interopRequireDefault(require("./ios/IosParser"));
var _IosFilter = _interopRequireDefault(require("./ios/IosFilter"));
var _simulator = require("./ios/simulator");
var _errors = require("./errors");
var _constants2 = require("./ios/constants");
var _formatters = require("./formatters");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* Common */
/* Android */
/* iOS */
/* Exports */
function makeTagsFilter(...tags) {
return (platform, minPriority) => {
const filter = platform === 'android' ? new _AndroidFilter.default(minPriority) : new _IosFilter.default(minPriority);
return minPriority => {
const filter = new _AndroidFilter.AndroidFilter(minPriority);
filter.setFilterByTag(tags);

@@ -85,8 +62,4 @@ return filter;

function makeAppFilter(appIdentifier) {
return (platform, minPriority, adbPath) => {
if (platform !== 'android') {
throw new Error('App filter is only available for Android');
}
const filter = new _AndroidFilter.default(minPriority);
return (minPriority, adbPath) => {
const filter = new _AndroidFilter.AndroidFilter(minPriority);
filter.setFilterByApp(appIdentifier, adbPath);

@@ -98,4 +71,4 @@ return filter;

function makeMatchFilter(...regexes) {
return (platform, minPriority) => {
const filter = platform === 'android' ? new _AndroidFilter.default(minPriority) : new _IosFilter.default(minPriority);
return minPriority => {
const filter = new _AndroidFilter.AndroidFilter(minPriority);
filter.setFilterByMatch(regexes);

@@ -107,8 +80,4 @@ return filter;

function makeCustomFilter(...patterns) {
return (platform, minPriority) => {
if (platform !== 'android') {
throw new Error('Custom filter is only available for Android');
}
const filter = new _AndroidFilter.default(minPriority);
return minPriority => {
const filter = new _AndroidFilter.AndroidFilter(minPriority);
filter.setCustomFilter(patterns);

@@ -128,16 +97,10 @@ return filter;

if (!['ios', 'android'].some(availablePlatform => availablePlatform === platform)) {
throw new Error(`Platform ${platform} is not supported`);
if (platform !== 'android') {
emitter.emit('error', new Error(`Platform ${platform} is not supported`));
return emitter;
}
const parser = platform === 'android' ? new _AndroidParser.default() : new _IosParser.default();
let filter;
if (createFilter) {
filter = createFilter(platform, priority, adbPath);
} else {
filter = platform === 'android' ? new _AndroidFilter.default(priority) : new _IosFilter.default(priority);
}
const loggingProcess = platform === 'android' ? (0, _adb.runAndroidLoggingProcess)(adbPath) : (0, _simulator.runSimulatorLoggingProcess)();
const parser = new _AndroidParser.default();
const filter = createFilter ? createFilter(priority, adbPath) : new _AndroidFilter.AndroidFilter(priority);
const loggingProcess = (0, _adb.runLoggingProcess)(adbPath);
process.on('exit', () => {

@@ -147,12 +110,3 @@ loggingProcess.kill();

});
loggingProcess.stderr.on('data', errorData => {
if (platform === 'ios' && errorData.toString().includes('No devices are booted.')) {
emitter.emit('error', new _errors.CodeError(_errors.ERR_IOS_NO_SIMULATORS_BOOTED, 'No simulators are booted.'));
} else {
emitter.emit('error', new Error(errorData.toString()));
}
});
loggingProcess.stdout.on('data', raw => {
let entryToLog;
try {

@@ -163,3 +117,3 @@ const messages = parser.splitMessages(raw.toString());

if (filter.shouldInclude(entry)) {
entryToLog = entry;
emitter.emit('entry', entry);
}

@@ -170,6 +124,2 @@ });

}
if (entryToLog) {
emitter.emit('entry', entryToLog);
}
});

@@ -176,0 +126,0 @@ loggingProcess.stdout.on('error', error => {

@@ -13,117 +13,92 @@ "use strict";

const androidPriorityOptions = {
unknown: {
alias: ['U', 'u'],
const priorityOptions = {
U: {
alias: 'u',
boolean: true,
default: false,
describe: 'Unknown priority'
describe: 'unknown priority'
},
verbose: {
alias: ['V', 'v'],
V: {
alias: 'v',
boolean: true,
default: false,
describe: 'Verbose priority'
describe: 'verbose priority'
},
debug: {
alias: ['D', 'd'],
D: {
alias: 'd',
boolean: true,
default: false,
describe: 'Debug priority'
describe: 'debug priority'
},
info: {
alias: ['I', 'i'],
I: {
alias: 'i',
boolean: true,
default: false,
describe: 'Info priority'
describe: 'info priority'
},
warn: {
alias: ['W', 'w'],
W: {
alias: 'w',
boolean: true,
default: false,
describe: 'Warn priority'
describe: 'warn priority'
},
error: {
alias: ['E', 'e'],
E: {
alias: 'e',
boolean: true,
default: false,
describe: 'Error priority'
describe: 'error priority'
},
fatal: {
alias: ['F', 'f'],
F: {
alias: 'f',
boolean: true,
default: false,
describe: 'Fatal priority'
describe: 'fatal priority'
},
silent: {
alias: ['S', 's'],
S: {
alias: 's',
boolean: true,
default: false,
describe: 'Silent priority'
describe: 'silent priority'
}
};
const iosPriorityOptions = {
debug: {
alias: ['D', 'd'],
boolean: true,
default: false,
describe: 'Debug level'
},
info: {
alias: ['I', 'i'],
boolean: true,
default: false,
describe: 'Info level'
},
error: {
alias: ['E', 'e'],
boolean: true,
default: false,
describe: 'Error level'
}
};
const {
argv: {
_: [platform, filter],
_: [command],
...args
}
} = _yargs.default.usage('Usage: $0 [options] <platform>').command('android', 'Android', yargs => yargs.command('tag <tags ...>', 'Show logs matching given tags', androidPriorityOptions).command('app <appId>', 'Show logs from application with given identifier', androidPriorityOptions).command('match <regexes...>', 'Show logs matching given patterns', androidPriorityOptions).command('custom <patterns ...>', 'Filter using custom patterns <tag>:<priority>').command('all', 'Show all logs', androidPriorityOptions).demandCommand(1).option('adb-path', {
} = _yargs.default.usage('Usage: $0 [options] <command>').command('tag <tags ...>', 'Show logs matching given tags', priorityOptions).command('app <appId>', 'Show logs from application with given identifier', priorityOptions).command('match <regexes...>', 'Show logs matching given patterns', priorityOptions).command('custom <patterns ...>', 'Filter using custom patterns <tag>:<priority>').command('all', 'Show all logs', priorityOptions).demandCommand(1).option('adb-path', {
type: 'string',
describe: 'Use custom path to ADB'
}).example('$0 android tag MyTag', 'Filter logs to only include ones with MyTag tag').example('$0 android tag MyTag -I', 'Filter logs to only include ones with MyTag tag and priority INFO and above').example('$0 android app com.example.myApp', 'Show all logs from com.example.myApp').example('$0 android match device', 'Show all logs matching /device/gm regex').example('$0 android app com.example.myApp -E', 'Show all logs from com.example.myApp with priority ERROR and above').example('$0 android custom *:S MyTag:D', 'Silence all logs and show only ones with MyTag with priority DEBUG and above')).command('ios <filter>', 'ios', yargs => yargs.command('tag <tags ...>', 'Show logs matching given tags', iosPriorityOptions).command('match <regexes...>', 'Show logs matching given patterns', iosPriorityOptions).command('all', 'Show all logs', iosPriorityOptions).demandCommand(1).example('$0 ios tag MyTag', 'Filter logs to only include ones with MyTag tag').example('$0 ios tag MyTag -i', 'Filter logs to only include ones with MyTag tag and priority Info and Error').example('$0 ios match device', 'Show all logs matching /device/gm regex')).demandCommand(1).help('h').alias('h', 'help').alias('v', 'version').version();
}).example('$0 tag MyTag', 'Filter logs to only include ones with MyTag tag').example('$0 tag MyTag -I', 'Filter logs to only include ones with MyTag tag and priority INFO and above').example('$0 app com.example.myApp', 'Show all logs from com.example.myApp').example('$0 match device', 'Show all logs matching /device/gm regex').example('$0 app com.example.myApp -E', 'Show all logs from com.example.myApp with priority ERROR and above').example('$0 custom *:S MyTag:D', 'Silence all logs and show only ones with MyTag with priority DEBUG and above').help('h').alias('h', 'help').alias('v', 'version').version();
const selectedAndroidPriorities = {
unknown: Boolean(args.unknown),
verbose: Boolean(args.verbose),
debug: Boolean(args.debug),
info: Boolean(args.info),
warn: Boolean(args.warn),
error: Boolean(args.error),
fatal: Boolean(args.fatal),
silent: Boolean(args.silent)
const selectedPriorities = {
U: Boolean(args.u),
V: Boolean(args.v),
D: Boolean(args.d),
I: Boolean(args.i),
W: Boolean(args.w),
E: Boolean(args.e),
F: Boolean(args.f),
S: Boolean(args.s)
};
const selectedIosPriorities = {
debug: Boolean(args.debug),
info: Boolean(args.info),
error: Boolean(args.error)
};
try {
let createFilter;
let filter;
switch (filter) {
switch (command) {
case 'app':
createFilter = (0, _api.makeAppFilter)(args.appId);
filter = (0, _api.makeAppFilter)(args.appId);
break;
case 'tag':
createFilter = (0, _api.makeTagsFilter)(...args.tags);
filter = (0, _api.makeTagsFilter)(...args.tags);
break;
case 'match':
createFilter = (0, _api.makeMatchFilter)(...args.regexes.map(value => new RegExp(value, 'gm')));
filter = (0, _api.makeMatchFilter)(...args.regexes.map(value => new RegExp(value, 'gm')));
break;
case 'custom':
createFilter = (0, _api.makeCustomFilter)(...args.patterns);
filter = (0, _api.makeCustomFilter)(...args.patterns);
break;

@@ -136,5 +111,5 @@

const emitter = (0, _api.logkitty)({
platform: platform,
priority: platform === 'android' ? (0, _utils.getMinPriority)(_api.AndroidPriority, selectedAndroidPriorities, _api.AndroidPriority.DEBUG) : (0, _utils.getMinPriority)(_api.IosPriority, selectedIosPriorities, _api.IosPriority.DEFAULT),
filter: createFilter
platform: 'android',
priority: (0, _utils.getMinPriority)(selectedPriorities),
filter
});

@@ -152,3 +127,3 @@ emitter.on('entry', entry => {

function terminate(error) {
// eslint-disable-next-line no-console
// tslint:disable-next-line: no-console
console.log((0, _formatters.formatError)(error));

@@ -155,0 +130,0 @@ process.exit(1);

@@ -5,9 +5,6 @@ export declare class CodeError extends Error {

}
export declare const ERR_ANDROID_UNPROCESSABLE_PID = "ERR_ANDROID_UNPROCESSABLE_PID";
export declare const ERR_ANDROID_CANNOT_GET_APP_PID = "ERR_ANDROID_CANNOT_GET_APP_PID";
export declare const ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER = "ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER";
export declare const ERR_ANDROID_CANNOT_START_LOGCAT = "ERR_ANDROID_CANNOT_START_LOGCAT";
export declare const ERR_IOS_CANNOT_LIST_SIMULATORS = "ERR_IOS_CANNOT_LIST_SIMULATORS";
export declare const ERR_IOS_NO_SIMULATORS_BOOTED = "ERR_IOS_NO_SIMULATORS_BOOTED";
export declare const ERR_IOS_CANNOT_START_SYSLOG = "ERR_IOS_CANNOT_START_SYSLOG";
export declare const ERR_UNPROCESSABLE_PID = "ERR_UNPROCESSABLE_PID";
export declare const ERR_CANNOT_GET_APP_PID = "ERR_CANNOT_GET_APP_PID";
export declare const ERR_CANNOT_CLEAN_LOGCAT_BUFFER = "ERR_CANNOT_CLEAN_LOGCAT_BUFFER";
export declare const ERR_CANNOT_START_LOGCAT = "ERR_CANNOT_START_LOGCAT";
//# sourceMappingURL=errors.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

});
exports.ERR_IOS_CANNOT_START_SYSLOG = exports.ERR_IOS_NO_SIMULATORS_BOOTED = exports.ERR_IOS_CANNOT_LIST_SIMULATORS = exports.ERR_ANDROID_CANNOT_START_LOGCAT = exports.ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER = exports.ERR_ANDROID_CANNOT_GET_APP_PID = exports.ERR_ANDROID_UNPROCESSABLE_PID = exports.CodeError = void 0;
exports.ERR_CANNOT_START_LOGCAT = exports.ERR_CANNOT_CLEAN_LOGCAT_BUFFER = exports.ERR_CANNOT_GET_APP_PID = exports.ERR_UNPROCESSABLE_PID = exports.CodeError = void 0;

@@ -23,16 +23,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

exports.CodeError = CodeError;
const ERR_ANDROID_UNPROCESSABLE_PID = 'ERR_ANDROID_UNPROCESSABLE_PID';
exports.ERR_ANDROID_UNPROCESSABLE_PID = ERR_ANDROID_UNPROCESSABLE_PID;
const ERR_ANDROID_CANNOT_GET_APP_PID = 'ERR_ANDROID_CANNOT_GET_APP_PID';
exports.ERR_ANDROID_CANNOT_GET_APP_PID = ERR_ANDROID_CANNOT_GET_APP_PID;
const ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER = 'ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER';
exports.ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER = ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER;
const ERR_ANDROID_CANNOT_START_LOGCAT = 'ERR_ANDROID_CANNOT_START_LOGCAT';
exports.ERR_ANDROID_CANNOT_START_LOGCAT = ERR_ANDROID_CANNOT_START_LOGCAT;
const ERR_IOS_CANNOT_LIST_SIMULATORS = 'ERR_IOS_CANNOT_LIST_SIMULATORS';
exports.ERR_IOS_CANNOT_LIST_SIMULATORS = ERR_IOS_CANNOT_LIST_SIMULATORS;
const ERR_IOS_NO_SIMULATORS_BOOTED = 'ERR_IOS_NO_SIMULATORS_BOOTED';
exports.ERR_IOS_NO_SIMULATORS_BOOTED = ERR_IOS_NO_SIMULATORS_BOOTED;
const ERR_IOS_CANNOT_START_SYSLOG = 'ERR_IOS_CANNOT_START_SYSLOG';
exports.ERR_IOS_CANNOT_START_SYSLOG = ERR_IOS_CANNOT_START_SYSLOG;
const ERR_UNPROCESSABLE_PID = 'ERR_UNPROCESSABLE_PID';
exports.ERR_UNPROCESSABLE_PID = ERR_UNPROCESSABLE_PID;
const ERR_CANNOT_GET_APP_PID = 'ERR_CANNOT_GET_APP_PID';
exports.ERR_CANNOT_GET_APP_PID = ERR_CANNOT_GET_APP_PID;
const ERR_CANNOT_CLEAN_LOGCAT_BUFFER = 'ERR_CANNOT_CLEAN_LOGCAT_BUFFER';
exports.ERR_CANNOT_CLEAN_LOGCAT_BUFFER = ERR_CANNOT_CLEAN_LOGCAT_BUFFER;
const ERR_CANNOT_START_LOGCAT = 'ERR_CANNOT_START_LOGCAT';
exports.ERR_CANNOT_START_LOGCAT = ERR_CANNOT_START_LOGCAT;
//# sourceMappingURL=errors.js.map

@@ -13,4 +13,2 @@ "use strict";

var _constants2 = require("./ios/constants");
function formatError(error) {

@@ -23,12 +21,15 @@ return (0, _ansiFragments.container)((0, _ansiFragments.color)('red', '✖︎ Ups, something went wrong'), (0, _ansiFragments.pad)(2, '\n'), (0, _ansiFragments.color)('red', (0, _ansiFragments.modifier)('bold', 'CODE'), ' ▶︎ '), 'code' in error ? error.code : 'ERR_UNKNOWN', (0, _ansiFragments.pad)(1, '\n'), (0, _ansiFragments.color)('red', (0, _ansiFragments.modifier)('bold', 'MESSAGE'), ' ▶︎ '), error.message).build();

let priorityModifier = 'none';
let messageColor = 'none';
if (entry.platform === 'android' && entry.priority >= _constants.Priority.ERROR || entry.platform === 'ios' && entry.priority >= _constants2.Priority.ERROR) {
if (entry.priority === _constants.Priority.FATAL || entry.priority === _constants.Priority.ERROR) {
priorityColor = 'red';
} else if (entry.platform === 'android' && entry.priority === _constants.Priority.WARN) {
messageColor = 'red';
} else if (entry.priority === _constants.Priority.WARN) {
priorityColor = 'yellow';
} else if (entry.platform === 'android' && entry.priority === _constants.Priority.VERBOSE || entry.platform === 'ios' && entry.priority === _constants2.Priority.DEBUG) {
messageColor = 'yellow';
} else if (entry.priority === _constants.Priority.VERBOSE) {
priorityModifier = 'dim';
}
const output = (0, _ansiFragments.container)((0, _ansiFragments.modifier)('dim', parseDate(entry.date)), (0, _ansiFragments.pad)(1), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, `${entry.platform === 'android' ? _constants.Priority.toLetter(entry.priority) : _constants2.Priority.toLetter(entry.priority)} |`)), (0, _ansiFragments.pad)(1), (0, _ansiFragments.modifier)('bold', (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, entry.tag || entry.appId || ''))), (0, _ansiFragments.pad)(1), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, '▶︎')), (0, _ansiFragments.pad)(1), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, entry.messages[0])), (0, _ansiFragments.ifElse)(entry.messages.length > 1, (0, _ansiFragments.container)(...entry.messages.slice(1).map((line, index, arr) => (0, _ansiFragments.container)((0, _ansiFragments.pad)(1, '\n'), (0, _ansiFragments.pad)((entry.tag || entry.appId || '').length + 16), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityColor === 'none' ? 'dim' : 'none', `${index === arr.length - 1 ? '└' : '│'} `)), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, line))))), '')).build();
const output = (0, _ansiFragments.container)((0, _ansiFragments.modifier)('dim', parseDate(entry.date)), (0, _ansiFragments.pad)(1), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, `${_constants.Priority.toLetter(entry.priority)} |`)), (0, _ansiFragments.pad)(1), (0, _ansiFragments.modifier)('bold', (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, entry.tag))), (0, _ansiFragments.pad)(1), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, '▶︎')), (0, _ansiFragments.pad)(1), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, entry.messages[0])), (0, _ansiFragments.ifElse)(entry.messages.length > 1, (0, _ansiFragments.container)(...entry.messages.slice(1).map((line, index, arr) => (0, _ansiFragments.container)((0, _ansiFragments.pad)(1, '\n'), (0, _ansiFragments.pad)(entry.tag.length + 16), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityColor === 'none' ? 'dim' : 'none', `${index === arr.length - 1 ? '└' : '│'} `)), (0, _ansiFragments.color)(priorityColor, (0, _ansiFragments.modifier)(priorityModifier, line))))), '')).build();
return `${output}\n`;

@@ -35,0 +36,0 @@ }

@@ -1,2 +0,1 @@

export declare type Platform = 'ios' | 'android';
export declare type Entry = {

@@ -6,6 +5,4 @@ date: Date;

priority: number;
tag?: string;
appId?: string;
tag: string;
messages: string[];
platform: Platform;
};

@@ -12,0 +9,0 @@ export interface IParser {

@@ -1,6 +0,4 @@

export declare function getMinPriority(Priority: {
fromName: (key: any) => number;
}, priorities: {
export declare function getMinPriority(priorities: {
[key: string]: boolean;
}, defaultPriority: number): number;
}, defaultPriority?: number): number;
//# sourceMappingURL=utils.d.ts.map

@@ -8,5 +8,7 @@ "use strict";

function getMinPriority(Priority, priorities, defaultPriority) {
var _constants = require("./android/constants");
function getMinPriority(priorities, defaultPriority = _constants.Priority.DEBUG) {
const parsedPriorities = Object.keys(priorities).filter(key => priorities[key]).map(key => {
return Priority.fromName(key);
return _constants.Priority.fromLetter(key) || _constants.Priority.SILENT;
});

@@ -13,0 +15,0 @@ return parsedPriorities.length ? Math.min(...parsedPriorities) : defaultPriority;

{
"name": "logkitty",
"version": "0.4.1",
"description": "Display pretty Android and iOS logs without Android Studio or Console.app, with intuitive Command Line Interface.",
"version": "0.4.2",
"description": "Display pretty Logcat logs without Android Studio with intuitive Command Line Interface.",
"keywords": [

@@ -10,7 +10,2 @@ "logcat",

"android studio",
"ios",
"Console.app",
"console",
"log",
"logs",
"logging"

@@ -31,3 +26,2 @@ ],

"files": [
"docs",
"bin",

@@ -54,3 +48,3 @@ "build"

"@babel/preset-typescript": "^7.3.3",
"@callstack/eslint-config": "^4.2.0",
"@callstack/eslint-config": "^4.1.0",
"@types/jest": "^24.0.11",

@@ -65,6 +59,3 @@ "@types/node": "^10.12.18",

"typescript": "^3.2.4"
},
"jest": {
"testRegex": "/__tests__/.*\\.(test|spec)\\.ts?$"
}
}

@@ -10,3 +10,3 @@ # logkitty

Display __pretty__ Android and iOS logs __without Android Studio or Console.app__, with __intuitive__ Command Line Interface.
Display __pretty__ Logcat logs __without Android Studio__ with __intuitive__ Command Line Interface.

@@ -31,56 +31,38 @@ ![Demo](./logkitty.gif)

```bash
logkitty <platform> <command> [options]
logkitty <command> [options]
```
### Command line help
You can inspect available platforms, command and options for a given platform by adding `-h` at the end, for example:
```bash
logkitty -h # prints available platforms and global options
logkitty android -h # prints commands and options for android
logkitty android tag -h # prints tag command syntax and options for android
```
### Commands
* platform: `android`:
* `tag <tags...>` - Show logs with matching tags.
* `app <appId>` - Show logs from application with given identifier.
* `match <regexes...>` - Show logs matching given patterns (all regexes have flags `g` and `m`).
* `custom <patterns...>` - Use custom [patters supported by Logcat](https://developer.android.com/studio/command-line/logcat#filteringOutput).
* `all` - Show all logs.
* platform: `ios`:
* `tag <tags...>` - Show logs with matching tags (where tag is usually a name of the app).
* `match <regexes...>` - Show logs matching given patterns (all regexes have flags `g` and `m`).
* `all` - Show all logs.
* `tag <tags...>` - Show logs with matching tags.
* `app <appId>` - Show logs from application with given identifier.
* `match <regexes...>` - Show logs matching given patterns (all regexes have flags `g` and `m`).
* `custom <patterns...>` - Use custom [patters supported by Logcat](https://developer.android.com/studio/command-line/logcat#filteringOutput).
* `all` - Show all logs.
### Options
* common:
* `-h, --help` - Display help
* `-v, --version` - Display version
* platform `android`:
`tag`, `app`, `match` and `all` commands support additional priority filtering options (sorted by priority):
#### Common
* `-U, -u` - Unknown priority (lowest)
* `-v, -v` - Verbose priority
* `-D, -d` - Debug priority (default)
* `-I, -i` - Info priority
* `-W, -w` - Warn priority
* `-E, -e` - Error priority
* `-F, -f` - Fatal priority
* `-S, -s` - Silent priority (highest)
All command accept the following options:
For example `logkitty all -W` will display all logs with priority __warn__, __error__ and __fatal__.
* `--adb-path <path>` - Custom path to ADB executable/binary.
* `-h, --help` - Display help
* `-v, --version` - Display version
* platform `ios`:
#### Specific
`tag`, `match` and `all` commands support additional level filtering options:
`tag`, `app`, `match` and `all` commands support additional filtering options (sorted by priority):
* `-D, -d` - Debug level
* `-I, -i` - Info level
* `-E, -e` - Error level
* `-U, -u` - Unknown priority (lowest)
* `-v, -v` - Verbose priority
* `-D, -d` - Debug priority (default)
* `-I, -i` - Info priority
* `-W, -w` - Warn priority
* `-E, -e` - Error priority
* `-F, -f` - Fatal priority
* `-S, -s` - Silent priority (highest)
For example `logkitty all -W` will display all logs with priority __warn__, __error__ and __fatal__.
### Examples

@@ -91,4 +73,3 @@

```
logkitty android tag ReactNativeJS
logkitty ios tag ReactNativeJS
logkitty tag ReactNativeJS
```

@@ -99,3 +80,3 @@

```
logkitty android app com.example.myApplication -i
logkitty app com.example.myApplication -i
```

@@ -106,11 +87,9 @@

```
logkitty android match CodePush
logkitty ios match CodePush
logkitty match CodePush
```
Show all logs with priority __error__ or __fatal__ for Android and __error_ level for iOS:
Show all logs with priority __error__ or __fatal__:
```
logkitty android all -e
logkitty ios all -e
logkitty all -e
```

@@ -121,10 +100,73 @@

```
logkitty android custom *:S my-tag:D
logkitty custom *:S my-tag:D
```
### Node API
## Node API
If your building a tool and want to use Node API, head over to [Node API documentation](./docs/NODE_API.md).
### Example:
```ts
import {
logkitty,
makeTagsFilter,
formatEntry,
formatError,
Priority,
Entry,
} from 'logkitty';
const emitter = logkitty({
platform: 'android',
minPriority: Priority.VERBOSE,
filter: makeTagsFilter('ReactNative', 'ReactNativeJS'),
});
emitter.on('entry', (entry: Entry) => {
console.log(formatEntry(entry));
});
emitter.on('error', (error: Error) => {
console.log(formatError(error));
});
```
#### `logkitty(options: LogkittyOptions): EventEmitter`
Spawns logkitty with given options:
* `platform: 'android'` - Platform, currently the only supported one is `android`.
* `adbPath?: string` - Custom path to ADB tool or `undefined`.
* `priority?: number` - Minimum priority of entries to show of `undefined`, which will include all entries with priority **DEBUG** or above.
* `filter?: FilterCreator` - The returned value from `makeTagsFilter`/`makeAppFilter`/`makeMatchFilter`/`makeCustomFilter` or `undefined`, which will include all entries (similar to `all` command in the CLI).
When spawning logkitty you will get a instance of `EventEmitter` which emitts the following events:
* `entry` (arguments: `entry: Entry`) - Emitted when new log comes in, that matches the `filter` and `priority` options. It is your responsibility to print or use that entry, for example you can use `formatEntry` to print it with the same styling as in the CLI.
* `error` (arguments: `error: Error`) - Emitted when the log can't be parsed into a entry or when the Logcat process emits an error. You can use `formatError` to print it with the same styling as in the CLI.
#### `makeTagsFilter(...tags: string[]): FilterCreator`
Creates a filter from given tags (for example `ReactNative`, `ReactNativeJS`), so only entries matching any of the given tags will be emitted in `entry` event. Pass the returned value to `filter` property when running `logkitty`.
#### `makeAppFilter(appIdentifier: string): FilterCreator`
Creates a filter for given application identifier (for example `com.example.app`), so only entries from given app will be emitted in `entry` event. Pass the returned value to `filter` property when running `logkitty`.
#### `makeMatchFilter(...regexes: RegExp[]): FilterCreator`
Creates a filter from given regexes (for example `/ReactNative/gm`, `/ReactNativeJS/gm`), so only entries matching any of the given regexes will be emitted in `entry` event. Pass the returned value to `filter` property when running `logkitty`.
#### `makeCustomFilter(...patterns: string[]): FilterCreator`
Creates a custom filter (for example `*:S`, `ReactNative:D`, `Hello:E`), so only entries matching given patterns will be emitted in `entry` event. Pass the returned value to `filter` property when running `logkitty`.
#### `formatEntry(entry: Entry): string`
Takes an entry as formats it to a string with ANSI escape codes for coloring.
#### `formatError(error: Error): string`
Takes an error and formats it to a string with ANSI escape codes for coloring.
<!-- badges (common) -->

@@ -131,0 +173,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc