Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime Device OS logging configuration #481

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const webhook = require('./webhook');
const whoami = require('./whoami');
const mesh = require('./mesh');
const usb = require('./usb');
const log = require('./log');

/**
* The default function export from this module registers all the available commands.
Expand Down Expand Up @@ -66,5 +67,6 @@ module.exports = function registerAllCommands(context) {
whoami(context);
mesh(context);
usb(context);
log(context);
alias(context);
};
46 changes: 46 additions & 0 deletions src/cli/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const settings = require('../../settings');

function logCommand() {
if (!logCommand._instance) {
const LogCommand = require('../cmd/log');
logCommand._instance = new LogCommand(settings);
}
return logCommand._instance;
}

module.exports = ({ commandProcessor, root }) => {
commandProcessor.createCommand(root, 'log', 'Display log messages from a device', {
params: '<device> [stream] [serial_port]',
options: {
'level': {
description: 'Default logging level',
string: true,
alias: 'l'
},
'filter': {
description: 'Category filter',
string: true,
alias: 'f'
},
'baud': {
description: 'Baud rate',
number: true,
alias: 'b'
},
'raw': {
description: 'Display raw logging output',
boolean: true
}
},
examples: {
'$0 $command my_device': 'Start reading and displaying log messages from the device "my_device"',
'$0 $command my_device -l none -f app:all': 'Show only application messages',
'$0 $command my_device -l warn -f app:all': 'Show all application messages as well as system warnings and errors',
'$0 $command my_device Serial1': 'Use the hardware serial interface for logging',
'$0 $command my_device Serial1 /dev/ttyUSB0': 'Use the specified serial port instead of auto-detecting'
},
handler: (args) => {
return logCommand().run(args);
}
});
};
Loading