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
a73c5b33
Commit
a73c5b33
authored
Sep 25, 2016
by
neil
Browse files
support log level
parent
eb59817e
Changes
1
Show whitespace changes
Inline
Side-by-side
acme.sh
View file @
a73c5b33
...
@@ -48,6 +48,12 @@ RENEW_SKIP=2
...
@@ -48,6 +48,12 @@ RENEW_SKIP=2
ECC_SEP
=
"_"
ECC_SEP
=
"_"
ECC_SUFFIX
=
"
${
ECC_SEP
}
ecc"
ECC_SUFFIX
=
"
${
ECC_SEP
}
ecc"
LOG_LEVEL_1
=
1
LOG_LEVEL_2
=
2
LOG_LEVEL_3
=
3
DEFAULT_LOG_LEVEL
=
"
$LOG_LEVEL_1
"
_DEBUG_WIKI
=
"https://github.com/Neilpang/acme.sh/wiki/How-to-debug-acme.sh"
__INTERACTIVE
=
""
__INTERACTIVE
=
""
if
[
-t
1
]
;
then
if
[
-t
1
]
;
then
...
@@ -74,66 +80,65 @@ __red() {
...
@@ -74,66 +80,65 @@ __red() {
fi
fi
}
}
__mytee
()
{
tee
-a
$1
}
_
info
()
{
_
printargs
()
{
if
[
-z
"
$2
"
]
;
then
if
[
-z
"
$2
"
]
;
then
printf
--
"[
$(
date
)
]
$1
"
| __mytee
$LOG_FILE
printf
--
"[
$(
date
)
]
$1
"
else
else
printf
--
"[
$(
date
)
]
$1
='
$2
'"
| __mytee
$LOG_FILE
printf
--
"[
$(
date
)
]
$1
='
$2
'"
fi
fi
printf
"
\n
"
| __mytee
$LOG_FILE
printf
"
\n
"
}
}
_err_e
()
{
_log
()
{
if
[
-z
"
$2
"
]
;
then
[
-z
"
$LOG_FILE
"
]
&&
return
__red
"
$1
"
| __mytee
$LOG_FILE
>
&2
_printargs
"
$@
"
>>
"
$LOG_FILE
"
else
}
__red
"
$1
='
$2
'"
| __mytee
$LOG_FILE
>
&2
fi
_info
()
{
printf
"
\n
"
| __mytee
$LOG_FILE
>
&2
_log
"
$@
"
_printargs
"
$@
"
}
}
_err
()
{
_err
()
{
printf
--
"[
$(
date
)
] "
| __mytee
$LOG_FILE
>
&2
_log
"
$@
"
_
err_e
"
$@
"
_
_red
"
$(
_printargs
"
$@
"
)
"
>
&2
return
1
return
1
}
}
_usage
()
{
_usage
()
{
_
err_e
"
$@
"
_
_red
"
$@
"
}
}
_debug
()
{
_debug
()
{
if
[
-z
"
$LOG_LEVEL
"
]
||
[
"
$LOG_LEVEL
"
-ge
"
$LOG_LEVEL_1
"
]
;
then
_log
"
$@
"
fi
if
[
-z
"
$DEBUG
"
]
;
then
if
[
-z
"
$DEBUG
"
]
;
then
return
return
fi
fi
_printargs
"
$@
"
>
&2
if
[
-z
"
$2
"
]
;
then
printf
--
"[
$(
date
)
]
$1
"
| __mytee
$LOG_FILE
>
&2
else
printf
--
"[
$(
date
)
]
$1
='
$2
'"
| __mytee
$LOG_FILE
>
&2
fi
printf
"
\n
"
| __mytee
$LOG_FILE
>
&2
return
0
}
}
_debug2
()
{
_debug2
()
{
if
[
"
$LOG_LEVEL
"
]
&&
[
"
$LOG_LEVEL
"
-ge
"
$LOG_LEVEL_2
"
]
;
then
_log
"
$@
"
fi
if
[
"
$DEBUG
"
]
&&
[
"
$DEBUG
"
-ge
"2"
]
;
then
if
[
"
$DEBUG
"
]
&&
[
"
$DEBUG
"
-ge
"2"
]
;
then
_debug
"
$@
"
_debug
"
$@
"
fi
fi
return
}
}
_debug3
()
{
_debug3
()
{
if
[
"
$LOG_LEVEL
"
]
&&
[
"
$LOG_LEVEL
"
-ge
"
$LOG_LEVEL_3
"
]
;
then
_log
"
$@
"
fi
if
[
"
$DEBUG
"
]
&&
[
"
$DEBUG
"
-ge
"3"
]
;
then
if
[
"
$DEBUG
"
]
&&
[
"
$DEBUG
"
-ge
"3"
]
;
then
_debug
"
$@
"
_debug
"
$@
"
fi
fi
return
}
}
_startswith
(){
_startswith
(){
...
@@ -1726,6 +1731,13 @@ _on_before_issue() {
...
@@ -1726,6 +1731,13 @@ _on_before_issue() {
}
}
_on_issue_err
()
{
_on_issue_err
()
{
if
[
"
$LOG_FILE
"
]
;
then
_err
"Please check log file for more details:
$LOG_FILE
"
else
_err
"Please use add '--debug' or '--log' to check more details."
_err
"See:
$_DEBUG_WIKI
"
fi
#run the post hook
#run the post hook
if
[
"
$Le_PostHook
"
]
;
then
if
[
"
$Le_PostHook
"
]
;
then
_info
"Run post hook:'
$Le_PostHook
'"
_info
"Run post hook:'
$Le_PostHook
'"
...
@@ -2971,6 +2983,7 @@ _initconf() {
...
@@ -2971,6 +2983,7 @@ _initconf() {
#LOG_FILE=
\"
$DEFAULT_LOG_FILE
\"
#LOG_FILE=
\"
$DEFAULT_LOG_FILE
\"
LOG_LEVEL=1
#AUTO_UPGRADE=
\"
1
\"
#AUTO_UPGRADE=
\"
1
\"
...
@@ -3312,6 +3325,7 @@ Parameters:
...
@@ -3312,6 +3325,7 @@ Parameters:
--keylength, -k [2048] Specifies the domain key length: 2048, 3072, 4096, 8192 or ec-256, ec-384.
--keylength, -k [2048] Specifies the domain key length: 2048, 3072, 4096, 8192 or ec-256, ec-384.
--accountkeylength, -ak [2048] Specifies the account key length.
--accountkeylength, -ak [2048] Specifies the account key length.
--log [/path/to/logfile] Specifies the log file. The default is:
\"
$DEFAULT_LOG_FILE
\"
if you don't give a file path here.
--log [/path/to/logfile] Specifies the log file. The default is:
\"
$DEFAULT_LOG_FILE
\"
if you don't give a file path here.
--log-level 1|2 Specifies the log level, default is 1.
These parameters are to install the cert to nginx/apache or anyother server after issue/renew a cert:
These parameters are to install the cert to nginx/apache or anyother server after issue/renew a cert:
...
@@ -3442,6 +3456,7 @@ _process() {
...
@@ -3442,6 +3456,7 @@ _process() {
_logfile
=
""
_logfile
=
""
_log
=
""
_log
=
""
_local_address
=
""
_local_address
=
""
_log_level
=
""
while
[
${#}
-gt
0
]
;
do
while
[
${#}
-gt
0
]
;
do
case
"
${
1
}
"
in
case
"
${
1
}
"
in
...
@@ -3739,8 +3754,15 @@ _process() {
...
@@ -3739,8 +3754,15 @@ _process() {
shift
shift
fi
fi
LOG_FILE
=
"
$_logfile
"
LOG_FILE
=
"
$_logfile
"
if
[
-z
"
$LOG_LEVEL
"
]
;
then
LOG_LEVEL
=
"
$DEFAULT_LOG_LEVEL
"
fi
;;
--log-level
)
_log_level
=
"
$1
"
LOG_LEVEL
=
"
$_log_level
"
shift
;;
;;
*
)
*
)
_err
"Unknown parameter :
$1
"
_err
"Unknown parameter :
$1
"
return
1
return
1
...
@@ -3759,6 +3781,12 @@ _process() {
...
@@ -3759,6 +3781,12 @@ _process() {
_saveaccountconf
"LOG_FILE"
"
$_logfile
"
_saveaccountconf
"LOG_FILE"
"
$_logfile
"
fi
fi
LOG_FILE
=
"
$_logfile
"
LOG_FILE
=
"
$_logfile
"
if
[
"
$_log_level
"
]
;
then
_saveaccountconf
"LOG_LEVEL"
"
$_log_level
"
LOG_LEVEL
=
"
$_log_level
"
fi
_processAccountConf
_processAccountConf
fi
fi
...
@@ -3837,6 +3865,10 @@ _process() {
...
@@ -3837,6 +3865,10 @@ _process() {
fi
fi
_saveaccountconf
"LOG_FILE"
"
$LOG_FILE
"
_saveaccountconf
"LOG_FILE"
"
$LOG_FILE
"
fi
fi
if
[
"
$_log_level
"
]
;
then
_saveaccountconf
"LOG_LEVEL"
"
$_log_level
"
fi
_processAccountConf
_processAccountConf
fi
fi
...
...
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