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
Hide 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 @@
...
@@ -9,6 +9,11 @@
default, syslog(3) is used for logging. Log levels correspond
default, syslog(3) is used for logging. Log levels correspond
to the 'priorities' defined by syslog(3).
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
-f varnishlog_bindump
A binary dump of the Varnish SHM log produced by 'varnishlog
A binary dump of the Varnish SHM log produced by 'varnishlog
-w'. If this option is specified, trackrdrd reads from the
-w'. If this option is specified, trackrdrd reads from the
...
...
trackrdrd/src/log.c
View file @
a6bd34ad
...
@@ -35,12 +35,16 @@
...
@@ -35,12 +35,16 @@
#include <stdarg.h>
#include <stdarg.h>
#include <strings.h>
#include <strings.h>
#include <string.h>
#include <string.h>
#include <ctype.h>
#include "trackrdrd.h"
#include "trackrdrd.h"
#include "libvarnish.h"
#include "libvarnish.h"
static
const
char
*
level2name
[
LOG_DEBUG
];
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
static
void
syslog_setlevel
(
int
level
)
syslog_setlevel
(
int
level
)
...
@@ -48,6 +52,22 @@ syslog_setlevel(int level)
...
@@ -48,6 +52,22 @@ syslog_setlevel(int level)
setlogmask
(
LOG_UPTO
(
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? */
/* XXX: is this safe? */
static
void
static
void
stdio_initnames
(
void
)
stdio_initnames
(
void
)
...
@@ -88,15 +108,23 @@ stdio_close(void)
...
@@ -88,15 +108,23 @@ stdio_close(void)
fclose
(
logconf
.
out
);
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
)
{
if
(
dest
==
NULL
)
{
/* syslog */
/* 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
.
log
=
syslog
;
logconf
.
setlevel
=
syslog_setlevel
;
logconf
.
setlevel
=
syslog_setlevel
;
logconf
.
close
=
closelog
;
logconf
.
close
=
closelog
;
openlog
(
progname
,
LOG_PID
|
LOG_CONS
|
LOG_NDELAY
|
LOG_NOWAIT
,
openlog
(
progname
,
LOG_PID
|
LOG_CONS
|
LOG_NDELAY
|
LOG_NOWAIT
,
fac
);
LOG_USER
);
setlogmask
(
LOG_UPTO
(
LOG_INFO
));
setlogmask
(
LOG_UPTO
(
LOG_INFO
));
atexit
(
closelog
);
atexit
(
closelog
);
return
(
0
);
return
(
0
);
...
@@ -106,8 +134,10 @@ int LOG_Open(const char *progname, const char *dest)
...
@@ -106,8 +134,10 @@ int LOG_Open(const char *progname, const char *dest)
logconf
.
out
=
stdout
;
logconf
.
out
=
stdout
;
else
{
else
{
logconf
.
out
=
fopen
(
dest
,
"w"
);
logconf
.
out
=
fopen
(
dest
,
"w"
);
if
(
logconf
.
out
==
NULL
)
if
(
logconf
.
out
==
NULL
)
{
perror
(
dest
);
return
(
-
1
);
return
(
-
1
);
}
}
}
logconf
.
level
=
LOG_INFO
;
logconf
.
level
=
LOG_INFO
;
logconf
.
log
=
stdio_log
;
logconf
.
log
=
stdio_log
;
...
...
trackrdrd/src/trackrdrd.c
View file @
a6bd34ad
...
@@ -76,10 +76,10 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
...
@@ -76,10 +76,10 @@ OSL_Track(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
int
datalen
;
int
datalen
;
char
*
data
;
char
*
data
;
(
void
)
priv
;
(
void
)
bitmap
;
(
void
)
bitmap
;
#if 1
#if 1
(
void
)
spec
;
(
void
)
spec
;
(
void
)
priv
;
(
void
)
fd
;
(
void
)
fd
;
#endif
#endif
#if 0
#if 0
...
@@ -191,14 +191,15 @@ main(int argc, char * const *argv)
...
@@ -191,14 +191,15 @@ main(int argc, char * const *argv)
{
{
int
c
;
int
c
;
int
D_flag
=
0
,
d_flag
=
0
;
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
vpf_fh
*
pfh
=
NULL
;
struct
VSM_data
*
vd
;
struct
VSM_data
*
vd
;
vd
=
VSM_New
();
vd
=
VSM_New
();
VSL_Setup
(
vd
);
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
)
{
switch
(
c
)
{
case
'D'
:
case
'D'
:
D_flag
=
1
;
D_flag
=
1
;
...
@@ -221,6 +222,9 @@ main(int argc, char * const *argv)
...
@@ -221,6 +222,9 @@ main(int argc, char * const *argv)
case
'f'
:
case
'f'
:
f_arg
=
optarg
;
f_arg
=
optarg
;
break
;
break
;
case
'y'
:
y_arg
=
optarg
;
break
;
case
'h'
:
case
'h'
:
usage
(
EXIT_SUCCESS
);
usage
(
EXIT_SUCCESS
);
default:
default:
...
@@ -233,14 +237,15 @@ main(int argc, char * const *argv)
...
@@ -233,14 +237,15 @@ main(int argc, char * const *argv)
if
(
f_arg
&&
n_arg
)
if
(
f_arg
&&
n_arg
)
usage
(
EXIT_FAILURE
);
usage
(
EXIT_FAILURE
);
if
(
l_arg
&&
y_arg
)
usage
(
EXIT_FAILURE
);
if
(
f_arg
&&
VSL_Arg
(
vd
,
'r'
,
f_arg
)
<=
0
)
if
(
f_arg
&&
VSL_Arg
(
vd
,
'r'
,
f_arg
)
<=
0
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
else
if
(
n_arg
&&
VSL_Arg
(
vd
,
'n'
,
n_arg
)
<=
0
)
else
if
(
n_arg
&&
VSL_Arg
(
vd
,
'n'
,
n_arg
)
<=
0
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
if
(
LOG_Open
(
PACKAGE_NAME
,
l_arg
)
!=
0
)
{
if
(
LOG_Open
(
PACKAGE_NAME
,
l_arg
,
y_arg
)
!=
0
)
{
perror
(
l_arg
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
d_flag
)
if
(
d_flag
)
...
@@ -273,13 +278,9 @@ main(int argc, char * const *argv)
...
@@ -273,13 +278,9 @@ main(int argc, char * const *argv)
/* Only read the VSL tags relevant to tracking */
/* Only read the VSL tags relevant to tracking */
assert
(
VSL_Arg
(
vd
,
'i'
,
TRACK_TAGS
)
>
0
);
assert
(
VSL_Arg
(
vd
,
'i'
,
TRACK_TAGS
)
>
0
);
while
(
VSL_Dispatch
(
vd
,
OSL_Track
,
stdout
)
>=
0
)
{
while
(
VSL_Dispatch
(
vd
,
OSL_Track
,
NULL
)
>=
0
)
if
(
fflush
(
stdout
)
!=
0
)
{
;
perror
(
"stdout"
);
break
;
}
}
/* XXX: Parent removes PID */
/* XXX: Parent removes PID */
if
(
pfh
!=
NULL
)
if
(
pfh
!=
NULL
)
VPF_Remove
(
pfh
);
VPF_Remove
(
pfh
);
...
...
trackrdrd/src/trackrdrd.h
View file @
a6bd34ad
...
@@ -44,7 +44,7 @@ struct logconf {
...
@@ -44,7 +44,7 @@ struct logconf {
int
level
;
int
level
;
}
logconf
;
}
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 ... */
/* XXX: __VA_ARGS__ can't be empty ... */
#define LOG_Log0(level, msg) logconf.log(level, msg)
#define LOG_Log0(level, msg) logconf.log(level, msg)
#define LOG_Log(level, msg, ...) logconf.log(level, msg, __VA_ARGS__)
#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]
[-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