@ -1,5 +1,6 @@
package main
import "os"
import "fmt"
import "github.com/sirupsen/logrus"
import "github.com/sneak/sircd/sircd"
@ -7,22 +8,22 @@ import "github.com/spf13/viper"
var Version string
var Buildtime string
var Builduser string
var Buildarch string
func main ( ) {
// set up logging
log := logrus . New ( )
log . SetLevel ( logrus . DebugLevel )
log . SetReportCaller ( true )
log . Println ( "sircd starting up" )
c := viper . New ( )
// default config variables
c . SetDefault ( "myhostname" , "irc.example.com" )
c . SetDefault ( "network" , "ExampleNet" )
c . SetDefault ( "admin" , "webmaster@example.com" )
c . SetDefault ( "loglevel" , "info" )
c . SetDefault ( "version" , Version )
c . SetDefault ( "buildtime" , Buildtime )
c . SetDefault ( "builduser" , Builduser )
c . SetDefault ( "buildarch" , Buildarch )
// read config file
c . SetConfigName ( "sircd" ) // name of config file (without extension)
@ -34,6 +35,24 @@ func main() {
panic ( fmt . Errorf ( "Fatal error config file: %s \n" , err ) )
}
// this is the only config settable by env var by design
// do everything else in the config file
if os . Getenv ( "DEBUG" ) != "" {
c . Set ( "loglevel" , "debug" )
}
// set up logging
log := logrus . New ( )
log . SetReportCaller ( false )
switch c . GetString ( "loglevel" ) {
case "error" :
log . SetLevel ( logrus . ErrorLevel )
case "info" :
log . SetLevel ( logrus . InfoLevel )
default :
log . SetLevel ( logrus . DebugLevel )
log . SetReportCaller ( true )
}
// instantiate server
s := sircd . New ( c )
// give it our logger