Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2bc31e55
Commit
2bc31e55
authored
May 13, 2013
by
antirez
Browse files
CONFIG REWRITE: support for save and syslog-facility.
parent
7e049faf
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/config.c
View file @
2bc31e55
...
...
@@ -31,6 +31,22 @@
#include "redis.h"
static
struct
{
const
char
*
name
;
const
int
value
;
}
validSyslogFacilities
[]
=
{
{
"user"
,
LOG_USER
},
{
"local0"
,
LOG_LOCAL0
},
{
"local1"
,
LOG_LOCAL1
},
{
"local2"
,
LOG_LOCAL2
},
{
"local3"
,
LOG_LOCAL3
},
{
"local4"
,
LOG_LOCAL4
},
{
"local5"
,
LOG_LOCAL5
},
{
"local6"
,
LOG_LOCAL6
},
{
"local7"
,
LOG_LOCAL7
},
{
NULL
,
0
}
};
/*-----------------------------------------------------------------------------
* Config file parsing
*----------------------------------------------------------------------------*/
...
...
@@ -164,21 +180,6 @@ void loadServerConfigFromString(char *config) {
if
(
server
.
syslog_ident
)
zfree
(
server
.
syslog_ident
);
server
.
syslog_ident
=
zstrdup
(
argv
[
1
]);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"syslog-facility"
)
&&
argc
==
2
)
{
struct
{
const
char
*
name
;
const
int
value
;
}
validSyslogFacilities
[]
=
{
{
"user"
,
LOG_USER
},
{
"local0"
,
LOG_LOCAL0
},
{
"local1"
,
LOG_LOCAL1
},
{
"local2"
,
LOG_LOCAL2
},
{
"local3"
,
LOG_LOCAL3
},
{
"local4"
,
LOG_LOCAL4
},
{
"local5"
,
LOG_LOCAL5
},
{
"local6"
,
LOG_LOCAL6
},
{
"local7"
,
LOG_LOCAL7
},
{
NULL
,
0
}
};
int
i
;
for
(
i
=
0
;
validSyslogFacilities
[
i
].
name
;
i
++
)
{
...
...
@@ -1298,9 +1299,33 @@ void rewriteConfigEnumOption(struct rewriteConfigState *state, char *option, int
}
void
rewriteConfigSyslogfacilityOption
(
struct
rewriteConfigState
*
state
)
{
int
value
=
server
.
syslog_facility
,
j
;
int
force
=
value
!=
LOG_LOCAL0
;
char
*
name
,
*
option
=
"syslog-facility"
;
sds
line
;
for
(
j
=
0
;
validSyslogFacilities
[
j
].
name
;
j
++
)
{
if
(
validSyslogFacilities
[
j
].
value
==
value
)
{
name
=
(
char
*
)
validSyslogFacilities
[
j
].
name
;
break
;
}
}
line
=
sdscatprintf
(
sdsempty
(),
"%s %s"
,
option
,
name
);
rewriteConfigRewriteLine
(
state
,
option
,
line
,
force
);
}
void
rewriteConfigSaveOption
(
struct
rewriteConfigState
*
state
)
{
int
j
;
sds
line
;
/* Note that if there are no save parameters at all, all the current
* config line with "save" will be detected as orphaned and deleted,
* resulting into no RDB persistence as expected. */
for
(
j
=
0
;
j
<
server
.
saveparamslen
;
j
++
)
{
line
=
sdscatprintf
(
sdsempty
(),
"save %ld %d"
,
server
.
saveparams
[
j
].
seconds
,
server
.
saveparams
[
j
].
changes
);
rewriteConfigRewriteLine
(
state
,
"save"
,
line
,
1
);
}
}
void
rewriteConfigDirOption
(
struct
rewriteConfigState
*
state
)
{
...
...
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