Skip to content

Commit

Permalink
Add some logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
kujtimiihoxha committed Apr 10, 2017
1 parent c520590 commit be49181
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
3 changes: 3 additions & 0 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,14 @@ func (sg *ServiceInitGenerator) Generate(name string) error {
func (sg *ServiceInitGenerator) generateTransport(name string, iface *parser.Interface, transport string) error {
switch transport {
case "http":
logrus.Info("Selected http transport.")
return sg.generateHttpTransport(name, iface)
default:
return errors.New(fmt.Sprintf("Transport `%s` not supported", transport))
}
}
func (sg *ServiceInitGenerator) generateHttpTransport(name string, iface *parser.Interface) error {
logrus.Info("Generating http transport...")
te := template.NewEngine()
defaultFs := fs.Get()
handlerFile := parser.NewFile()
Expand Down Expand Up @@ -329,6 +331,7 @@ func (sg *ServiceInitGenerator) generateHttpTransport(name string, iface *parser
return defaultFs.WriteFile(tfile, handlerFile.String(), false)
}
func (sg *ServiceInitGenerator) generateEndpoints(name string, iface *parser.Interface) error {
logrus.Info("Generating endpoints...")
te := template.NewEngine()
defaultFs := fs.Get()
enpointsPath, err := te.ExecuteString(viper.GetString("endpoints.path"), map[string]string{
Expand Down
20 changes: 3 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"github.com/Sirupsen/logrus"
"github.com/kujtimiihoxha/gk/cmd"
"github.com/spf13/viper"
"strings"
"os"
"github.com/Sirupsen/logrus"
"strings"
)

func main() {
Expand All @@ -30,7 +16,7 @@ func main() {
logrus.Error(err)
return
}
if !strings.HasPrefix(pwd,gosrc) {
if !strings.HasPrefix(pwd, gosrc) {
logrus.Error("The project must be in the $GOPATH/src folder for the generator to work.")
return
}
Expand Down

0 comments on commit be49181

Please sign in to comment.