Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
fb068f80
Commit
fb068f80
authored
Dec 13, 2018
by
Sietse Ringers
Browse files
Make verbosity configurable
parent
5e4c2f59
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/irmaserver/cmd/main.go
View file @
fb068f80
...
...
@@ -2,6 +2,7 @@ package main
import
(
"encoding/json"
"io/ioutil"
"os"
"github.com/Sirupsen/logrus"
...
...
@@ -29,6 +30,11 @@ func main() {
},
}
logger
.
Level
=
logrus
.
InfoLevel
logger
.
SetFormatter
(
&
logrus
.
TextFormatter
{
FullTimestamp
:
true
,
})
if
err
:=
setFlags
(
cmd
);
err
!=
nil
{
die
(
errors
.
WrapPrefix
(
err
,
"Failed to attach flags"
,
0
))
}
...
...
@@ -40,7 +46,7 @@ func main() {
func
die
(
err
*
errors
.
Error
)
{
logger
.
Error
(
err
.
Error
())
logger
.
Debug
(
string
(
err
.
Stack
()))
logger
.
Trace
(
string
(
err
.
Stack
()))
os
.
Exit
(
1
)
}
...
...
@@ -63,12 +69,9 @@ func setFlags(cmd *cobra.Command) error {
flags
.
Lookup
(
"signing"
)
.
NoOptDefVal
=
"*"
flags
.
Lookup
(
"issuing"
)
.
NoOptDefVal
=
"*"
return
viper
.
BindPFlags
(
flags
)
}
func
configure
()
error
{
logger
.
Level
=
logrus
.
TraceLevel
logger
.
Debugf
(
"Configuring"
)
flags
.
BoolP
(
"verbose"
,
"v"
,
false
,
"verbose"
)
flags
.
Bool
(
"vverbose"
,
false
,
"more verbose"
)
flags
.
BoolP
(
"quiet"
,
"q"
,
false
,
"quiet"
)
// Environment variables
viper
.
SetEnvPrefix
(
"IRMASERVER"
)
...
...
@@ -79,7 +82,24 @@ func configure() error {
viper
.
AddConfigPath
(
"."
)
viper
.
AddConfigPath
(
"/etc/irmaserver/"
)
viper
.
AddConfigPath
(
"$HOME/.irmaserver"
)
if
err
:=
viper
.
ReadInConfig
();
err
!=
nil
{
return
viper
.
BindPFlags
(
flags
)
}
func
configure
()
error
{
err
:=
viper
.
ReadInConfig
()
// Hold error checking until we know how much of it to log
if
viper
.
GetBool
(
"verbose"
)
{
logger
.
Level
=
logrus
.
DebugLevel
}
if
viper
.
GetBool
(
"vverbose"
)
{
logger
.
Level
=
logrus
.
TraceLevel
}
if
viper
.
GetBool
(
"quiet"
)
{
logger
.
Out
=
ioutil
.
Discard
}
logger
.
Debugf
(
"Configuring"
)
if
err
!=
nil
{
logger
.
Info
(
"No configuration file found"
)
}
else
{
logger
.
Info
(
"Config file: "
,
viper
.
ConfigFileUsed
())
...
...
@@ -98,6 +118,8 @@ func configure() error {
GlobalPermissions
:
irmaserver
.
Permissions
{},
JwtIssuer
:
viper
.
GetString
(
"jwtissuer"
),
JwtPrivateKey
:
viper
.
GetString
(
"jwtprivatekey"
),
Verbose
:
viper
.
GetBool
(
"verbose"
),
VVerbose
:
viper
.
GetBool
(
"vverbose"
),
}
// Handle global permissions
...
...
server/irmaserver/conf.go
View file @
fb068f80
...
...
@@ -32,6 +32,10 @@ type Configuration struct {
// Private key to sign result JWTs with. If absent, /result-jwt and /getproof are disabled.
JwtPrivateKey
string
`json:"jwtprivatekey" mapstructure:"jwtprivatekey"`
Verbose
bool
VVerbose
bool
Quiet
bool
jwtPrivateKey
*
rsa
.
PrivateKey
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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