-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
181 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package config | ||
|
||
import ( | ||
"flag" | ||
|
||
"go.deanishe.net/env" | ||
) | ||
|
||
var ( | ||
entity = flag.String("entity", env.Get(GO_MA_ACTOR_ENTITY_VAR, defaultEntity), | ||
"DID of the entity to communicate with. You can use environment variable "+GO_MA_ACTOR_ENTITY_VAR+" to set this.") | ||
) | ||
|
||
func GetEntity() string { | ||
return *entity | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package config | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"go.deanishe.net/env" | ||
) | ||
|
||
var ( | ||
|
||
// Logging | ||
logLevel = flag.String("loglevel", env.Get(GO_MA_ACTOR_LOGLEVEL_VAR, defaultLogLevel), | ||
"Loglevel to use for application. You can use environment variable "+GO_MA_ACTOR_LOGLEVEL_VAR+" to set this.") | ||
logfile = flag.String("logfile", env.Get(GO_MA_ACTOR_LOGFILE_VAR, defaultLogfile), | ||
"Logfile to use for application. You can use environment variable "+GO_MA_ACTOR_LOGFILE_VAR+" to set this.") | ||
) | ||
|
||
func InitLogging() { | ||
|
||
// Init logger | ||
level, err := log.ParseLevel(*logLevel) | ||
if err != nil { | ||
log.Error(err) | ||
os.Exit(64) // EX_USAGE | ||
} | ||
log.SetLevel(level) | ||
file, err := os.OpenFile(name+".log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644) | ||
if err != nil { | ||
log.Errorf("Failed to open log file: %v", err) | ||
os.Exit(73) // EX_CANTCREAT | ||
} | ||
log.SetOutput(file) | ||
|
||
log.Info("Logger initialized") | ||
|
||
} | ||
|
||
func GetLogLevel() string { | ||
return *logLevel | ||
} | ||
|
||
func GetLogFile() string { | ||
return *logfile | ||
} |
Oops, something went wrong.