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
Acme.Sh
Commits
fc6cf4d9
Commit
fc6cf4d9
authored
Feb 19, 2017
by
neilpang
Browse files
fix syslog
parent
db504629
Changes
1
Show whitespace changes
Inline
Side-by-side
acme.sh
View file @
fc6cf4d9
...
@@ -65,10 +65,31 @@ LOG_LEVEL_2=2
...
@@ -65,10 +65,31 @@ LOG_LEVEL_2=2
LOG_LEVEL_3=3
LOG_LEVEL_3=3
DEFAULT_LOG_LEVEL="$LOG_LEVEL_1"
DEFAULT_LOG_LEVEL="$LOG_LEVEL_1"
SYSLOG_INFO="user.info"
DEBUG_LEVEL_1=1
DEBUG_LEVEL_2=2
DEBUG_LEVEL_3=3
DEBUG_LEVEL_DEFAULT=$DEBUG_LEVEL_1
DEBUG_LEVEL_NONE=0
SYSLOG_ERROR="user.error"
SYSLOG_ERROR="user.error"
SYSLOG_INFO="user.info"
SYSLOG_DEBUG="user.debug"
SYSLOG_DEBUG="user.debug"
#error
SYSLOG_LEVEL_1=1
#info
SYSLOG_LEVEL_2=2
#debug
SYSLOG_LEVEL_3=3
#debug2
SYSLOG_LEVEL_4=4
#debug3
SYSLOG_LEVEL_5=5
SYSLOG_LEVEL_DEFAULT=$SYSLOG_LEVEL_1
#none
SYSLOG_LEVEL_NONE=0
_DEBUG_WIKI="https://github.com/Neilpang/acme.sh/wiki/How-to-debug-acme.sh"
_DEBUG_WIKI="https://github.com/Neilpang/acme.sh/wiki/How-to-debug-acme.sh"
_PREPARE_LINK="https://github.com/Neilpang/acme.sh/wiki/Install-preparations"
_PREPARE_LINK="https://github.com/Neilpang/acme.sh/wiki/Install-preparations"
...
@@ -138,7 +159,7 @@ _dlg_versions() {
...
@@ -138,7 +159,7 @@ _dlg_versions() {
#class
#class
_syslog() {
_syslog() {
if [
-z
"$SYS_LOG
" ] || [ "
$SYS
_
LOG
" = "0
" ]; then
if [ "$
{
SYS_LOG
:-
$SYSLOG
_LEVEL_NONE}" = "$SYSLOG_LEVEL_NONE
" ]; then
return
return
fi
fi
_logclass="$1"
_logclass="$1"
...
@@ -147,19 +168,21 @@ _syslog() {
...
@@ -147,19 +168,21 @@ _syslog() {
}
}
_log() {
_log() {
_syslog "$@"
[ -z "$LOG_FILE" ] && return
[ -z "$LOG_FILE" ] && return
shift
_printargs "$@" >>"$LOG_FILE"
_printargs "$@" >>"$LOG_FILE"
}
}
_info() {
_info() {
_log "$SYSLOG_INFO" "$@"
_log "$@"
if [ "${SYS_LOG:-$SYSLOG_LEVEL_NONE}" -ge "$SYSLOG_LEVEL_2" ]; then
_syslog "$SYSLOG_INFO" "$@"
fi
_printargs "$@"
_printargs "$@"
}
}
_err() {
_err() {
_log "$SYSLOG_ERROR" "$@"
_syslog "$SYSLOG_ERROR" "$@"
_log "$@"
if [ -z "$NO_TIMESTAMP" ] || [ "$NO_TIMESTAMP" = "0" ]; then
if [ -z "$NO_TIMESTAMP" ] || [ "$NO_TIMESTAMP" = "0" ]; then
printf -- "%s" "[$(date)] " >&2
printf -- "%s" "[$(date)] " >&2
fi
fi
...
@@ -178,29 +201,37 @@ _usage() {
...
@@ -178,29 +201,37 @@ _usage() {
}
}
_debug() {
_debug() {
if [
-z
"$LOG_LEVEL
" ] || [ "$
LOG_LEVEL" -ge "$LOG_LEVEL_1" ]; then
if [ "$
{
LOG_LEVEL
:-$DEFAULT_
LOG_LEVEL
}
" -ge "$LOG_LEVEL_1" ]; then
_log
"$SYSLOG_DEBUG"
"$@"
_log "$@"
fi
fi
if [
-z "$DEBUG
" ]; then
if [
"${SYS_LOG:-$SYSLOG_LEVEL_NONE}" -ge "$SYSLOG_LEVEL_3
" ]; then
return
_syslog "$SYSLOG_DEBUG" "$@"
fi
fi
if [ "${DEBUG:-$DEBUG_LEVEL_NONE}" -ge "$DEBUG_LEVEL_1" ]; then
_printargs "$@" >&2
_printargs "$@" >&2
fi
}
}
_debug2() {
_debug2() {
if [ "$LOG_LEVEL
" ] && [ "$
LOG_LEVEL" -ge "$LOG_LEVEL_2" ]; then
if [ "$
{
LOG_LEVEL
:-$DEFAULT_
LOG_LEVEL
}
" -ge "$LOG_LEVEL_2" ]; then
_log
"$SYSLOG_DEBUG"
"$@"
_log "$@"
fi
fi
if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
if [ "${SYS_LOG:-$SYSLOG_LEVEL_NONE}" -ge "$SYSLOG_LEVEL_4" ]; then
_syslog "$SYSLOG_DEBUG" "$@"
fi
if [ "${DEBUG:-$DEBUG_LEVEL_NONE}" -ge "$DEBUG_LEVEL_2" ]; then
_printargs "$@" >&2
_printargs "$@" >&2
fi
fi
}
}
_debug3() {
_debug3() {
if [ "$LOG_LEVEL" ] && [ "$LOG_LEVEL" -ge "$LOG_LEVEL_3" ]; then
if [ "${LOG_LEVEL:-$DEFAULT_LOG_LEVEL}" -ge "$LOG_LEVEL_3" ]; then
_log "$SYSLOG_DEBUG" "$@"
_log "$@"
fi
if [ "${SYS_LOG:-$SYSLOG_LEVEL_NONE}" -ge "$SYSLOG_LEVEL_5" ]; then
_syslog "$SYSLOG_DEBUG" "$@"
fi
fi
if [ "$DEBUG
" ] && [ "$DEBUG" -ge "
3" ]; then
if [ "$
{
DEBUG
:-$DEBUG_LEVEL_NONE}" -ge "$DEBUG_LEVEL_
3" ]; then
_printargs "$@" >&2
_printargs "$@" >&2
fi
fi
}
}
...
@@ -4840,7 +4871,7 @@ _process() {
...
@@ -4840,7 +4871,7 @@ _process() {
;;
;;
--debug)
--debug)
if [ -z "$2" ] || _startswith "$2" "-"; then
if [ -z "$2" ] || _startswith "$2" "-"; then
DEBUG="
1
"
DEBUG="
$DEBUG_LEVEL_DEFAULT
"
else
else
DEBUG="$2"
DEBUG="$2"
shift
shift
...
@@ -5069,7 +5100,7 @@ _process() {
...
@@ -5069,7 +5100,7 @@ _process() {
shift
shift
fi
fi
if [ -z "$_syslog" ]; then
if [ -z "$_syslog" ]; then
_syslog="
1
"
_syslog="
$SYSLOG_LEVEL_DEFAULT
"
fi
fi
;;
;;
--auto-upgrade)
--auto-upgrade)
...
...
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