Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions conf.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[default]
cookiesecret = some secrete phrase
mapohome = /mapo/root/folder

[googleoauth]
clientid = client_id
clientsecret = client_secret
Binary file removed log/.log.go.swo
Binary file not shown.
81 changes: 0 additions & 81 deletions log/log.go

This file was deleted.

40 changes: 35 additions & 5 deletions mapo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,46 @@ along with Mapo. If not, see <http://www.gnu.org/licenses/>.
package main

import (
"mapo/log"
"github.com/maponet/utils/log"
"github.com/maponet/utils/conf"

"flag"
)

func main() {
// parse flags

/*
parse flags

In some situation we will pass path to configuration file as a command line
value. This meaning that for first off all we need to define and parse all flags.
The only flag that we required on this step is only conf flag ... But we
can't distribute code with same functionality along file or files.
*/
var logLevel = log.FlagLevel("log")
var confFilePath = flag.String("conf", "./conf.ini", "set path to configuration file")
flag.Parse()

// load config and setup application
log.SetLevel(log.DEBUG)
log.Info("Setting log level to DEBUG")
err := conf.ParseConfigFile(*confFilePath)
if err != nil {
log.Error("%v", err)
return
}

// setup configuration value passed as command line arguments
if len(*logLevel) > 0 {
conf.GlobalConfiguration.AddOption("default", "loglevel", *logLevel)
}

// setup application

// set log level
value, _ := conf.GlobalConfiguration.GetString("default", "loglevel")
if err := log.SetLevelString(value); err != nil {
log.Error("%v", err)
return
}

log.Info("Starting application")

Expand Down Expand Up @@ -64,7 +95,6 @@ func main() {

// return result to user


// close on signal
log.Info("Closing application")
}