Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
trackrdrd
Commits
a6bd34ad
Commit
a6bd34ad
authored
Sep 24, 2012
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trackrdrd: added the -y option to set the syslog facility
parent
b8d7200f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
19 deletions
+56
-19
options.txt
trackrdrd/options.txt
+5
-0
log.c
trackrdrd/src/log.c
+34
-4
trackrdrd.c
trackrdrd/src/trackrdrd.c
+14
-13
trackrdrd.h
trackrdrd/src/trackrdrd.h
+1
-1
synopsis.txt
trackrdrd/synopsis.txt
+2
-1
No files found.
trackrdrd/options.txt
View file @
a6bd34ad
...
...
@@ -9,6 +9,11 @@
default, syslog(3) is used for logging. Log levels correspond
to the 'priorities' defined by syslog(3).
-y syslog_facility
Set the syslog facility; legal values are 'user' or 'local0'
through 'local7', and the default is 'local0'. Options -y and
-l are mutually exclusive.
-f varnishlog_bindump
A binary dump of the Varnish SHM log produced by 'varnishlog
-w'. If this option is specified, trackrdrd reads from the
...
...
trackrdrd/src/log.c
View file @
a6bd34ad
...
...
@@ -35,12 +35,16 @@
#include <stdarg.h>
#include <strings.h>
#include <string.h>
#include <ctype.h>
#include "trackrdrd.h"
#include "libvarnish.h"
static
const
char
*
level2name
[
LOG_DEBUG
];
static
const
int
facilitynum
[
8
]
=
{
LOG_LOCAL0
,
LOG_LOCAL1
,
LOG_LOCAL2
,
LOG_LOCAL3
,
LOG_LOCAL4
,
LOG_LOCAL5
,
LOG_LOCAL6
,
LOG_LOCAL7
};
static
void
syslog_setlevel
(
int
level
)
...
...
@@ -48,6 +52,22 @@ syslog_setlevel(int level)
setlogmask
(
LOG_UPTO
(
level
));
}
static
int
syslog_getFacility
(
const
char
*
facility
)
{
int
localnum
;
if
(
strcasecmp
(
facility
,
"USER"
)
==
0
)
return
LOG_USER
;
if
(
strlen
(
facility
)
!=
6
||
strncasecmp
(
facility
,
"LOCAL"
,
5
)
!=
0
||
!
isdigit
(
facility
[
5
]))
return
(
-
1
);
localnum
=
atoi
(
&
facility
[
5
]);
if
(
localnum
>
7
)
return
(
-
1
);
return
(
facilitynum
[
localnum
]);
}
/* XXX: is this safe? */
static
void
stdio_initnames
(
void
)
...
...
@@ -88,15 +108,23 @@ stdio_close(void)
fclose
(
logconf
.
out
);
}
int
LOG_Open
(
const
char
*
progname
,
const
char
*
dest
)
int
LOG_Open
(
const
char
*
progname
,
const
char
*
dest
,
const
char
*
facility
)
{
if
(
dest
==
NULL
)
{
/* syslog */
int
fac
=
LOG_LOCAL0
;
if
(
facility
!=
NULL
)
{
fac
=
syslog_getFacility
(
facility
);
if
(
fac
<
0
)
{
fprintf
(
stderr
,
"Invalid facility: %s
\n
"
,
facility
);
return
(
-
1
);
}
}
logconf
.
log
=
syslog
;
logconf
.
setlevel
=
syslog_setlevel
;
logconf
.
close
=
closelog
;
openlog
(
progname
,
LOG_PID
|
LOG_CONS
|
LOG_NDELAY
|
LOG_NOWAIT
,
LOG_USER
);
openlog
(
progname
,
LOG_PID
|
LOG_CONS
|
LOG_NDELAY
|
LOG_NOWAIT
,
fac
);
setlogmask
(
LOG_UPTO
(
LOG_INFO
));
atexit
(
closelog
);
return
(
0
);
...
...
@@ -106,9 +134,11 @@ int LOG_Open(const char *progname, const char *dest)
logconf
.
out
=
stdout
;
else
{
logconf
.
out
=
fopen
(
dest
,
"w"
);
if
(
logconf
.
out
==
NULL
)
if
(
logconf
.
out
==
NULL
)
{
perror
(
dest
);
return
(
-
1
);
}
}
logconf
.
level
=
LOG_INFO
;
logconf
.
log
=
stdio_log
;
logconf
.
setlevel
=
stdio_setlevel
;
...
...
trackrdrd/src/trackrdrd.c
View file @
a6bd34ad
...
...
@@ -76,10 +76,10 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
int
datalen
;
char
*
data
;
(
void
)
priv
;
(
void
)
bitmap
;
#if 1
(
void
)
spec
;
(
void
)
priv
;
(
void
)
fd
;
#endif
#if 0
...
...
@@ -191,14 +191,15 @@ main(int argc, char * const *argv)
{
int
c
;
int
D_flag
=
0
,
d_flag
=
0
;
const
char
*
P_arg
=
NULL
,
*
l_arg
=
NULL
,
*
n_arg
=
NULL
,
*
f_arg
=
NULL
;
const
char
*
P_arg
=
NULL
,
*
l_arg
=
NULL
,
*
n_arg
=
NULL
,
*
f_arg
=
NULL
,
*
y_arg
=
NULL
;
struct
vpf_fh
*
pfh
=
NULL
;
struct
VSM_data
*
vd
;
vd
=
VSM_New
();
VSL_Setup
(
vd
);
while
((
c
=
getopt
(
argc
,
argv
,
"DP:Vn:hl:df:"
))
!=
-
1
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"DP:Vn:hl:df:
y:
"
))
!=
-
1
)
{
switch
(
c
)
{
case
'D'
:
D_flag
=
1
;
...
...
@@ -221,6 +222,9 @@ main(int argc, char * const *argv)
case
'f'
:
f_arg
=
optarg
;
break
;
case
'y'
:
y_arg
=
optarg
;
break
;
case
'h'
:
usage
(
EXIT_SUCCESS
);
default:
...
...
@@ -233,14 +237,15 @@ main(int argc, char * const *argv)
if
(
f_arg
&&
n_arg
)
usage
(
EXIT_FAILURE
);
if
(
l_arg
&&
y_arg
)
usage
(
EXIT_FAILURE
);
if
(
f_arg
&&
VSL_Arg
(
vd
,
'r'
,
f_arg
)
<=
0
)
exit
(
EXIT_FAILURE
);
else
if
(
n_arg
&&
VSL_Arg
(
vd
,
'n'
,
n_arg
)
<=
0
)
exit
(
EXIT_FAILURE
);
if
(
LOG_Open
(
PACKAGE_NAME
,
l_arg
)
!=
0
)
{
perror
(
l_arg
);
if
(
LOG_Open
(
PACKAGE_NAME
,
l_arg
,
y_arg
)
!=
0
)
{
exit
(
EXIT_FAILURE
);
}
if
(
d_flag
)
...
...
@@ -273,12 +278,8 @@ main(int argc, char * const *argv)
/* Only read the VSL tags relevant to tracking */
assert
(
VSL_Arg
(
vd
,
'i'
,
TRACK_TAGS
)
>
0
);
while
(
VSL_Dispatch
(
vd
,
OSL_Track
,
stdout
)
>=
0
)
{
if
(
fflush
(
stdout
)
!=
0
)
{
perror
(
"stdout"
);
break
;
}
}
while
(
VSL_Dispatch
(
vd
,
OSL_Track
,
NULL
)
>=
0
)
;
/* XXX: Parent removes PID */
if
(
pfh
!=
NULL
)
...
...
trackrdrd/src/trackrdrd.h
View file @
a6bd34ad
...
...
@@ -44,7 +44,7 @@ struct logconf {
int
level
;
}
logconf
;
int
LOG_Open
(
const
char
*
progname
,
const
char
*
dest
);
int
LOG_Open
(
const
char
*
progname
,
const
char
*
dest
,
const
char
*
facility
);
/* XXX: __VA_ARGS__ can't be empty ... */
#define LOG_Log0(level, msg) logconf.log(level, msg)
#define LOG_Log(level, msg, ...) logconf.log(level, msg, __VA_ARGS__)
...
...
trackrdrd/synopsis.txt
View file @
a6bd34ad
trackrdrd [-n varnish_name] [-l log_file] [-f varnishlog_bindump]
trackrdrd [[-n varnish_name] | [-f varnishlog_bindump]]
[[-l log_file] | [-y syslog_facility]]
[-d] [-V] [-h]
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