Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
logkeys
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
logkeys
Commits
02b32202
Commit
02b32202
authored
8 years ago
by
Ricardo Sateler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added option to print to standard output
parent
f6a1de2a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
logkeys.8
man/logkeys.8
+2
-0
logkeys.cc
src/logkeys.cc
+17
-2
usage.cc
src/usage.cc
+1
-1
No files found.
man/logkeys.8
View file @
02b32202
...
@@ -49,6 +49,8 @@ Set ouput log file to \fIlogfile\fR. If no \fB-o\fR option is provided, logkeys
...
@@ -49,6 +49,8 @@ Set ouput log file to \fIlogfile\fR. If no \fB-o\fR option is provided, logkeys
appends to \fI/var/log/logkeys.log\fR file. If \fIlogfile\fR doesn't exist, logkeys
appends to \fI/var/log/logkeys.log\fR file. If \fIlogfile\fR doesn't exist, logkeys
creates the file with 600 permissions.
creates the file with 600 permissions.
.IP
.IP
To print output to standard output, use '-' as logfile: \fB-o\fR \fI-\fR.
.IP
See also \fBLOGFILE FORMAT\fR section.
See also \fBLOGFILE FORMAT\fR section.
.TP
.TP
...
...
This diff is collapsed.
Click to expand it.
src/logkeys.cc
View file @
02b32202
...
@@ -393,6 +393,11 @@ int main(int argc, char **argv)
...
@@ -393,6 +393,11 @@ int main(int argc, char **argv)
if
(
!
args
.
keymap
.
empty
()
&&
(
!
(
args
.
flags
&
FLAG_EXPORT_KEYMAP
)
&&
args
.
us_keymap
))
{
// exporting uses args.keymap also
if
(
!
args
.
keymap
.
empty
()
&&
(
!
(
args
.
flags
&
FLAG_EXPORT_KEYMAP
)
&&
args
.
us_keymap
))
{
// exporting uses args.keymap also
error
(
EXIT_FAILURE
,
0
,
"Incompatible flags '-m' and '-u'. See usage."
);
error
(
EXIT_FAILURE
,
0
,
"Incompatible flags '-m' and '-u'. See usage."
);
}
}
// check for incompatible flags: if posting remote and output is set to stdout
if
(
args
.
post_size
!=
0
&&
(
args
.
logfile
==
"-"
))
{
error
(
EXIT_FAILURE
,
0
,
"Incompatible flags [--post-size | --post-http] and --output to stdout"
);
}
set_utf8_locale
();
set_utf8_locale
();
...
@@ -423,7 +428,11 @@ int main(int argc, char **argv)
...
@@ -423,7 +428,11 @@ int main(int argc, char **argv)
int
noclose
=
1
;
// don't close streams (stderr used)
int
noclose
=
1
;
// don't close streams (stderr used)
if
(
daemon
(
nochdir
,
noclose
)
==
-
1
)
// become daemon
if
(
daemon
(
nochdir
,
noclose
)
==
-
1
)
// become daemon
error
(
EXIT_FAILURE
,
errno
,
"Failed to become daemon"
);
error
(
EXIT_FAILURE
,
errno
,
"Failed to become daemon"
);
close
(
STDIN_FILENO
);
close
(
STDOUT_FILENO
);
// leave stderr open
close
(
STDIN_FILENO
);
// leave stderr open
if
(
args
.
logfile
!=
"-"
)
{
close
(
STDOUT_FILENO
);
}
// open input device for reading
// open input device for reading
input_fd
=
open
(
args
.
device
.
c_str
(),
O_RDONLY
);
input_fd
=
open
(
args
.
device
.
c_str
(),
O_RDONLY
);
...
@@ -439,7 +448,13 @@ int main(int argc, char **argv)
...
@@ -439,7 +448,13 @@ int main(int argc, char **argv)
// open log file (if file doesn't exist, create it with safe 0600 permissions)
// open log file (if file doesn't exist, create it with safe 0600 permissions)
umask
(
0177
);
umask
(
0177
);
FILE
*
out
=
fopen
(
args
.
logfile
.
c_str
(),
"a"
);
FILE
*
out
=
NULL
;
if
(
args
.
logfile
==
"-"
)
{
out
=
stdout
;
}
else
{
out
=
fopen
(
args
.
logfile
.
c_str
(),
"a"
);
}
if
(
!
out
)
if
(
!
out
)
error
(
EXIT_FAILURE
,
errno
,
"Error opening output file '%s'"
,
args
.
logfile
.
c_str
());
error
(
EXIT_FAILURE
,
errno
,
"Error opening output file '%s'"
,
args
.
logfile
.
c_str
());
...
...
This diff is collapsed.
Click to expand it.
src/usage.cc
View file @
02b32202
...
@@ -19,7 +19,7 @@ void usage()
...
@@ -19,7 +19,7 @@ void usage()
"
\n
"
"
\n
"
" -s, --start start logging keypresses
\n
"
" -s, --start start logging keypresses
\n
"
" -m, --keymap=FILE use keymap FILE
\n
"
" -m, --keymap=FILE use keymap FILE
\n
"
" -o, --output=FILE log output to FILE ["
DEFAULT_LOG_FILE
"]
\n
"
" -o, --output=FILE log output to FILE ["
DEFAULT_LOG_FILE
"]
or standard output '-'
\n
"
" -u, --us-keymap use en_US keymap instead of configured default
\n
"
" -u, --us-keymap use en_US keymap instead of configured default
\n
"
" -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
"
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment