Skip to content

Commit c823ae2

Browse files
author
Juan RP
authored
Merge pull request #26 from Duncaen/vlogger-logger
Vlogger
2 parents 95ad0a9 + 06c1ad4 commit c823ae2

2 files changed

Lines changed: 45 additions & 19 deletions

File tree

vlogger.8

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,35 @@
1212
.Op Fl t Ar tag
1313
.Op Ar message ...
1414
.Sh DESCRIPTION
15-
By default,
15+
The
1616
.Nm
17-
reads lines from
17+
utility writes messages to the system log.
18+
.Pp
19+
With
20+
.Ar message
21+
arguments
22+
.Nm
23+
will always write messages to the system log.
24+
Without
25+
.Ar message
26+
arguments
27+
.Nm
28+
reads messages from
1829
.Dv stdin
19-
and sends them to syslog.
20-
If the file
30+
or the file specified with the
31+
.Fl f
32+
flag.
33+
If the
2134
.Pa /etc/vlogger
22-
exists and is executable it is executed with
23-
.Ar tag
24-
as only argument and replaces
25-
.Nm .
35+
executable exists
36+
.Nm
37+
executes it with
38+
.Ar tag ,
39+
level
40+
and priority as arguments,
41+
replacing the
42+
.Nm
43+
process.
2644
.Pp
2745
If
2846
.Nm
@@ -34,18 +52,20 @@ supervision suite it uses the service name as default
3452
As example if
3553
.Nm
3654
is linked to
37-
.Dv /var/service/foo/log/run
55+
.Pa /var/service/foo/log/run
3856
it uses
39-
.Dv foo
40-
as default
57+
.Dq foo
58+
as
4159
.Ar tag .
4260
.Pp
4361
The options are as follows:
4462
.Bl -tag -width "-f file"
4563
.It Fl f Ar file
4664
Read lines from the specified
4765
.Ar file .
48-
This
66+
This option cannot be combine
67+
.Ar message
68+
arguments.
4969
.It Fl i
5070
Log the PID of the
5171
.Nm
@@ -66,7 +86,7 @@ See
6686
or
6787
.Xr syslog 3 .
6888
The default is
69-
.Pa daemon.info .
89+
.Dq user.notice .
7090
.It Fl S
7191
Force
7292
.Nm
@@ -87,6 +107,9 @@ Defines the
87107
.Pa ident
88108
which is used as prefix for each log message or passed as first argument to
89109
.Pa /etc/vlogger .
110+
The default is the
111+
.Ev LOGNAME
112+
environment variable.
90113
.It Ar message
91114
Write the
92115
.Ar message

vlogger.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ main(int argc, char *argv[])
7878
{
7979
char buf[1024];
8080
char *p, *argv0;
81-
char *tag = "vlogger";
81+
char *tag = NULL;
8282
int c;
8383
int Sflag = 0;
8484
int logflags = 0;
85-
int facility = LOG_DAEMON;
86-
int level = LOG_INFO;
85+
int facility = LOG_USER;
86+
int level = LOG_NOTICE;
8787

8888
argv0 = *argv;
8989

@@ -94,7 +94,7 @@ main(int argc, char *argv[])
9494
*p = '\0';
9595
if ((p = strrchr(pwd, '/')) && strncmp(p+1, "log", 3) == 0 &&
9696
(*p = '\0', (p = strrchr(pwd, '/'))) && (*(p+1) != '\0')) {
97-
tag = strdup(p+1);
97+
tag = p+1;
9898
}
9999
}
100100
}
@@ -119,9 +119,12 @@ main(int argc, char *argv[])
119119
argc -= optind;
120120
argv += optind;
121121

122+
if (argc > 0)
123+
Sflag++;
124+
122125
if (!Sflag && access("/etc/vlogger", X_OK) != -1) {
123126
CODE *cp;
124-
const char *sfacility, *slevel;
127+
const char *sfacility = "", *slevel = "";
125128
for (cp = prioritynames; cp->c_name; cp++) {
126129
if (cp->c_val == level)
127130
slevel = cp->c_name;
@@ -135,7 +138,7 @@ main(int argc, char *argv[])
135138
exit(1);
136139
}
137140

138-
openlog(tag, logflags, facility);
141+
openlog(tag ? tag : getlogin(), logflags, facility);
139142

140143
if (argc > 0) {
141144
size_t len;

0 commit comments

Comments
 (0)