Skip to content
GitLab
Menu
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
...
@@ -2,6 +2,7 @@ package main
import
(
import
(
"encoding/json"
"encoding/json"
"io/ioutil"
"os"
"os"
"github.com/Sirupsen/logrus"
"github.com/Sirupsen/logrus"
...
@@ -29,6 +30,11 @@ func main() {
...
@@ -29,6 +30,11 @@ func main() {
},
},
}
}
logger
.
Level
=
logrus
.
InfoLevel
logger
.
SetFormatter
(
&
logrus
.
TextFormatter
{
FullTimestamp
:
true
,
})
if
err
:=
setFlags
(
cmd
);
err
!=
nil
{
if
err
:=
setFlags
(
cmd
);
err
!=
nil
{
die
(
errors
.
WrapPrefix
(
err
,
"Failed to attach flags"
,
0
))
die
(
errors
.
WrapPrefix
(
err
,
"Failed to attach flags"
,
0
))
}
}
...
@@ -40,7 +46,7 @@ func main() {
...
@@ -40,7 +46,7 @@ func main() {
func
die
(
err
*
errors
.
Error
)
{
func
die
(
err
*
errors
.
Error
)
{
logger
.
Error
(
err
.
Error
())
logger
.
Error
(
err
.
Error
())
logger
.
Debug
(
string
(
err
.
Stack
()))
logger
.
Trace
(
string
(
err
.
Stack
()))
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
...
@@ -63,12 +69,9 @@ func setFlags(cmd *cobra.Command) error {
...
@@ -63,12 +69,9 @@ func setFlags(cmd *cobra.Command) error {
flags
.
Lookup
(
"signing"
)
.
NoOptDefVal
=
"*"
flags
.
Lookup
(
"signing"
)
.
NoOptDefVal
=
"*"
flags
.
Lookup
(
"issuing"
)
.
NoOptDefVal
=
"*"
flags
.
Lookup
(
"issuing"
)
.
NoOptDefVal
=
"*"
return
viper
.
BindPFlags
(
flags
)
flags
.
BoolP
(
"verbose"
,
"v"
,
false
,
"verbose"
)
}
flags
.
Bool
(
"vverbose"
,
false
,
"more verbose"
)
flags
.
BoolP
(
"quiet"
,
"q"
,
false
,
"quiet"
)
func
configure
()
error
{
logger
.
Level
=
logrus
.
TraceLevel
logger
.
Debugf
(
"Configuring"
)
// Environment variables
// Environment variables
viper
.
SetEnvPrefix
(
"IRMASERVER"
)
viper
.
SetEnvPrefix
(
"IRMASERVER"
)
...
@@ -79,7 +82,24 @@ func configure() error {
...
@@ -79,7 +82,24 @@ func configure() error {
viper
.
AddConfigPath
(
"."
)
viper
.
AddConfigPath
(
"."
)
viper
.
AddConfigPath
(
"/etc/irmaserver/"
)
viper
.
AddConfigPath
(
"/etc/irmaserver/"
)
viper
.
AddConfigPath
(
"$HOME/.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"
)
logger
.
Info
(
"No configuration file found"
)
}
else
{
}
else
{
logger
.
Info
(
"Config file: "
,
viper
.
ConfigFileUsed
())
logger
.
Info
(
"Config file: "
,
viper
.
ConfigFileUsed
())
...
@@ -98,6 +118,8 @@ func configure() error {
...
@@ -98,6 +118,8 @@ func configure() error {
GlobalPermissions
:
irmaserver
.
Permissions
{},
GlobalPermissions
:
irmaserver
.
Permissions
{},
JwtIssuer
:
viper
.
GetString
(
"jwtissuer"
),
JwtIssuer
:
viper
.
GetString
(
"jwtissuer"
),
JwtPrivateKey
:
viper
.
GetString
(
"jwtprivatekey"
),
JwtPrivateKey
:
viper
.
GetString
(
"jwtprivatekey"
),
Verbose
:
viper
.
GetBool
(
"verbose"
),
VVerbose
:
viper
.
GetBool
(
"vverbose"
),
}
}
// Handle global permissions
// Handle global permissions
...
...
server/irmaserver/conf.go
View file @
fb068f80
...
@@ -32,6 +32,10 @@ type Configuration struct {
...
@@ -32,6 +32,10 @@ type Configuration struct {
// Private key to sign result JWTs with. If absent, /result-jwt and /getproof are disabled.
// Private key to sign result JWTs with. If absent, /result-jwt and /getproof are disabled.
JwtPrivateKey
string
`json:"jwtprivatekey" mapstructure:"jwtprivatekey"`
JwtPrivateKey
string
`json:"jwtprivatekey" mapstructure:"jwtprivatekey"`
Verbose
bool
VVerbose
bool
Quiet
bool
jwtPrivateKey
*
rsa
.
PrivateKey
jwtPrivateKey
*
rsa
.
PrivateKey
}
}
...
...
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