added -q option
This commit is contained in:
parent
1bb82fa267
commit
bd76593058
|
@ -19,6 +19,7 @@ struct arguments
|
||||||
bool kill; // stop keylogger, -k switch
|
bool kill; // stop keylogger, -k switch
|
||||||
bool us_keymap; // use default US keymap, -u switch
|
bool us_keymap; // use default US keymap, -u switch
|
||||||
bool precise; // log with ms, -p switch
|
bool precise; // log with ms, -p switch
|
||||||
|
bool onlyms;
|
||||||
std::string logfile; // user-specified log filename, -o switch
|
std::string logfile; // user-specified log filename, -o switch
|
||||||
std::string keymap; // user-specified keymap file, -m switch or --export-keymap
|
std::string keymap; // user-specified keymap file, -m switch or --export-keymap
|
||||||
std::string device; // user-specified input event device, given with -d switch
|
std::string device; // user-specified input event device, given with -d switch
|
||||||
|
@ -64,7 +65,7 @@ void process_command_line_arguments(int argc, char **argv)
|
||||||
int c;
|
int c;
|
||||||
int option_index;
|
int option_index;
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "sm:o:ukpd:?", long_options, &option_index)) != -1)
|
while ((c = getopt_long(argc, argv, "sm:o:ukpqd:?", long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +76,8 @@ void process_command_line_arguments(int argc, char **argv)
|
||||||
case 'k': args.kill = true; break;
|
case 'k': args.kill = true; break;
|
||||||
case 'd': args.device = optarg; break;
|
case 'd': args.device = optarg; break;
|
||||||
case 'p': args.precise = true; break;
|
case 'p': args.precise = true; break;
|
||||||
|
case 'q': args.precise = args.onlyms = true; break;
|
||||||
|
|
||||||
case 0 :
|
case 0 :
|
||||||
args.flags |= flags;
|
args.flags |= flags;
|
||||||
switch (flags)
|
switch (flags)
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <chrono> // for precise time messureing
|
#include <chrono> // for precise time messureing
|
||||||
#include <iostream> //debug
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h> // include config produced from ./configure
|
# include <config.h> // include config produced from ./configure
|
||||||
|
@ -456,11 +455,16 @@ void init() {
|
||||||
|
|
||||||
std::string createStamp() {
|
std::string createStamp() {
|
||||||
std::chrono::time_point < std::chrono::system_clock > time = std::chrono::system_clock::now();
|
std::chrono::time_point < std::chrono::system_clock > time = std::chrono::system_clock::now();
|
||||||
time_t cur_time = std::chrono::system_clock::to_time_t(time);
|
auto time_ms = std::chrono::duration_cast < std::chrono::milliseconds > (time.time_since_epoch());
|
||||||
auto time_ms = std::chrono::duration_cast < std::chrono::milliseconds > (time - std::chrono::system_clock::from_time_t(cur_time));
|
std::string out = "";
|
||||||
char timestamp[32];
|
if(!args.onlyms) {
|
||||||
strftime(timestamp, sizeof(timestamp), TIME_FORMAT, localtime(&cur_time));
|
time_t cur_time = std::chrono::system_clock::to_time_t(time);
|
||||||
return std::string(timestamp) + std::to_string(time_ms.count()) + "ms : ";
|
time_ms = std::chrono::duration_cast < std::chrono::milliseconds > (time - std::chrono::system_clock::from_time_t(cur_time));
|
||||||
|
char timestamp[32];
|
||||||
|
strftime(timestamp, sizeof(timestamp), TIME_FORMAT, localtime(&cur_time));
|
||||||
|
out = std::string(timestamp);
|
||||||
|
}
|
||||||
|
return out + std::to_string(time_ms.count()) + "ms : ";
|
||||||
}
|
}
|
||||||
|
|
||||||
int printBeginStamp(FILE* out) {
|
int printBeginStamp(FILE* out) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ void usage()
|
||||||
" -k, --kill kill running logkeys process\n"
|
" -k, --kill kill running logkeys process\n"
|
||||||
" -d, --device=FILE input event device [eventX from " INPUT_EVENT_PATH "]\n"
|
" -d, --device=FILE input event device [eventX from " INPUT_EVENT_PATH "]\n"
|
||||||
" -p, --precise add milliseconds to the timestamp and add a timestamp to every press\n"
|
" -p, --precise add milliseconds to the timestamp and add a timestamp to every press\n"
|
||||||
|
" -q, only log the ms to create a esaier format for other programs to process"
|
||||||
" -?, --help print this help screen\n"
|
" -?, --help print this help screen\n"
|
||||||
" --export-keymap=FILE export configured keymap to FILE and exit\n"
|
" --export-keymap=FILE export configured keymap to FILE and exit\n"
|
||||||
" --no-func-keys log only character keys\n"
|
" --no-func-keys log only character keys\n"
|
||||||
|
|
Loading…
Reference in New Issue