Skip to content
This repository has been archived by the owner on Jan 9, 2018. It is now read-only.

Commit

Permalink
Add log stream name cli option
Browse files Browse the repository at this point in the history
  • Loading branch information
eyj committed Sep 29, 2016
1 parent a11d555 commit d7304ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func getLogLevel(priority string) (Priority, error) {
return DEBUG, fmt.Errorf("'%s' is unsupported log priority", priority)
}

func LoadConfig(filename string) (*Config, error) {
func LoadConfig(filename, logStreamName string) (*Config, error) {
configBytes, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
Expand Down Expand Up @@ -113,7 +113,9 @@ func LoadConfig(filename string) (*Config, error) {

config.LogGroupName = fConfig.LogGroupName

if fConfig.LogStreamName != "" {
if logStreamName != "" {
config.LogStreamName = logStreamName
} else if fConfig.LogStreamName != "" {
config.LogStreamName = fConfig.LogStreamName
} else {
// By default we use the instance id as the stream name.
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

var help = flag.Bool("help", false, "set to true to show this help")
var logStreamName = flag.String("S", "", "AWS log stream name")

func main() {
flag.Parse()
Expand Down Expand Up @@ -40,7 +41,7 @@ func usage() {
}

func run(configFilename string) error {
config, err := LoadConfig(configFilename)
config, err := LoadConfig(configFilename, *logStreamName)
if err != nil {
return fmt.Errorf("error reading config: %s", err)
}
Expand Down

0 comments on commit d7304ce

Please # to comment.