Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #58 from itskingori/logging_lowercase
Browse files Browse the repository at this point in the history
Start all logging output with lowercase
  • Loading branch information
itskingori committed May 20, 2018
2 parents 251c0c7 + 8797e7b commit dafe527
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

## 0.9.0

* Change all logging output to start with lowercase letters.

## 0.8.0

* Configure commands to not accept arguments i.e. `server`, `worker` and
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Expand Up @@ -39,7 +39,7 @@ var RootCmd = &cobra.Command{
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Printf("Failed executing command, %s\n", err)
fmt.Printf("failed executing command, %s\n", err)
os.Exit(-1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/server.go
Expand Up @@ -42,7 +42,7 @@ var serverCmd = &cobra.Command{
return nil
},
Run: func(cmd *cobra.Command, args []string) {
log.Info("Starting the server")
log.Info("starting the server")

client := service.NewClient()
client.StartServer()
Expand Down
4 changes: 2 additions & 2 deletions cmd/worker.go
Expand Up @@ -54,7 +54,7 @@ var workerCmd = &cobra.Command{
return nil
},
Run: func(cmd *cobra.Command, args []string) {
log.Info("Starting the worker")
log.Info("starting the worker")

client := service.NewClient()
client.StartWorker()
Expand Down Expand Up @@ -107,7 +107,7 @@ func validateS3Bucket(cmd *cobra.Command) error {
sbv, _ := cmd.Flags().GetString("s3-bucket")

if sbv == "" {
return fmt.Errorf("S3 bucket name cannot be empty, set --s3-bucket")
return fmt.Errorf("the S3 bucket name cannot be empty, set --s3-bucket")
}

return nil
Expand Down
22 changes: 11 additions & 11 deletions service/job.go
Expand Up @@ -56,7 +56,7 @@ func (cj *ConversionJob) markAsProcessing() {

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Info("Marked conversion job as 'processing'")
}).Info("marked conversion job as 'processing'")
}

func (cj *ConversionJob) markAsFailed() {
Expand All @@ -65,7 +65,7 @@ func (cj *ConversionJob) markAsFailed() {

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Info("Marked conversion job as 'failed'")
}).Info("marked conversion job as 'failed'")
}

func (cj *ConversionJob) markAsSucceeded() {
Expand All @@ -74,7 +74,7 @@ func (cj *ConversionJob) markAsSucceeded() {

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Info("Marked conversion job as 'succeeded'")
}).Info("marked conversion job as 'succeeded'")
}

func (clt *Client) enqueueConversionJob(riq string) error {
Expand Down Expand Up @@ -116,7 +116,7 @@ func (clt *Client) createAndSaveConversionJob(rid string, rR renderRequest) (Con
if err != nil {
log.WithFields(log.Fields{
"uuid": rid,
}).Error("Error saving conversion job")
}).Error("error saving conversion job")

return cj, err
}
Expand All @@ -125,7 +125,7 @@ func (clt *Client) createAndSaveConversionJob(rid string, rR renderRequest) (Con
if err != nil {
log.WithFields(log.Fields{
"uuid": rid,
}).Error("Error setting conversion job expiry")
}).Error("error setting conversion job expiry")

return cj, err
}
Expand All @@ -149,7 +149,7 @@ func (clt *Client) fetchConversionJob(jid string) (ConversionJob, bool, error) {
if err != nil {
log.WithFields(log.Fields{
"uuid": jid,
}).Error("Unable to fetch values from redis")
}).Error("unable to fetch values from redis")

return cj, found, err
}
Expand All @@ -163,15 +163,15 @@ func (clt *Client) fetchConversionJob(jid string) (ConversionJob, bool, error) {
if err != nil {
log.WithFields(log.Fields{
"uuid": jid,
}).Error("Unable to unmarshall values to job")
}).Error("unable to unmarshall values to job")

return cj, found, err
}
found = true

log.WithFields(log.Fields{
"uuid": jid,
}).Debug("Fetched conversion job details")
}).Debug("fetched conversion job details")

return cj, found, nil
}
Expand All @@ -184,7 +184,7 @@ func (clt *Client) updateConversionJob(cj *ConversionJob) error {
if err != nil {
log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Error("Unable to parse job identifier")
}).Error("unable to parse job identifier")

return err
}
Expand All @@ -195,14 +195,14 @@ func (clt *Client) updateConversionJob(cj *ConversionJob) error {
if err != nil {
log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Error("Error saving conversion job changes")
}).Error("error saving conversion job changes")

return err
}

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Debug("Saved conversion job changes")
}).Debug("saved conversion job changes")

return nil
}
26 changes: 13 additions & 13 deletions service/server.go
Expand Up @@ -157,7 +157,7 @@ func (clt *Client) renderHandler(w http.ResponseWriter, r *http.Request) {
default:
ers = errorResponse{
Identifier: rid,
Message: fmt.Sprintf("Invalid %s render request", target),
Message: fmt.Sprintf("invalid %s render request", target),
}
requestBadRequestResponse(&w, r, ers)

Expand All @@ -168,7 +168,7 @@ func (clt *Client) renderHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
ers = errorResponse{
Identifier: rid,
Message: fmt.Sprintf("Unable to unmarshal json to %s type", target),
Message: fmt.Sprintf("unable to unmarshal json to %s type", target),
}
requestBadRequestResponse(&w, r, ers)

Expand All @@ -179,21 +179,21 @@ func (clt *Client) renderHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
ers = errorResponse{
Identifier: rid,
Message: fmt.Sprintf("Unable to enqueue %s job", target),
Message: fmt.Sprintf("unable to enqueue %s job", target),
}
requestInternalServerErrorResponse(&w, r, ers)

return
}
log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Infof("Enqueued render %s job", target)
}).Infof("enqueued render %s job", target)

rrs, err := cj.generateRenderResponse(clt)
if err != nil {
ers = errorResponse{
Identifier: cj.Identifier,
Message: "Failed to generate render response",
Message: "failed to generate render response",
}
requestInternalServerErrorResponse(&w, r, ers)

Expand All @@ -213,7 +213,7 @@ func (clt *Client) statusHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
ers = errorResponse{
Identifier: jid,
Message: "Invalid job identifier",
Message: "invalid job identifier",
}
requestBadRequestResponse(&w, r, ers)

Expand All @@ -227,7 +227,7 @@ func (clt *Client) statusHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
ers = errorResponse{
Identifier: jid,
Message: "Unable to fetch conversion job",
Message: "unable to fetch conversion job",
}
requestInternalServerErrorResponse(&w, r, ers)

Expand All @@ -237,7 +237,7 @@ func (clt *Client) statusHandler(w http.ResponseWriter, r *http.Request) {
if !found {
ers = errorResponse{
Identifier: jid,
Message: "Request not found on conversion queue",
Message: "request not found on conversion queue",
}
requestNotFoundResponse(&w, r, ers)

Expand All @@ -248,7 +248,7 @@ func (clt *Client) statusHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
ers = errorResponse{
Identifier: cj.Identifier,
Message: "Failed to generate render response",
Message: "failed to generate render response",
}
requestInternalServerErrorResponse(&w, r, ers)

Expand All @@ -257,7 +257,7 @@ func (clt *Client) statusHandler(w http.ResponseWriter, r *http.Request) {

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Info("Conversion job status check completed")
}).Info("conversion job status check completed")

requestOKResponse(&w, r, rrs)
}
Expand Down Expand Up @@ -288,7 +288,7 @@ func (cj *ConversionJob) generateRenderResponse(clt *Client) (renderResponse, er

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Debugln("Conversion job found completed")
}).Debugln("conversion job found completed")

timeToExpire := 5 * time.Minute
surl, err := clt.getFileS3SignedURL(cj, timeToExpire)
Expand All @@ -307,7 +307,7 @@ func (cj *ConversionJob) generateRenderResponse(clt *Client) (renderResponse, er
// StartServer starts the application web server
func (clt *Client) StartServer() {
requestTTL := viper.GetInt("server.request_ttl")
log.Infof("Request TTL set to %d seconds", requestTTL)
log.Infof("request TTL set to %d seconds", requestTTL)

health := healthcheck.NewHandler()

Expand All @@ -333,7 +333,7 @@ func (clt *Client) StartServer() {
bindingPort := viper.GetInt("server.binding_port")
binding := fmt.Sprintf("%s:%d", bindingAddress, bindingPort)

log.Infof("Listening on http://%s", binding)
log.Infof("listening on http://%s", binding)
http.Handle("/", router)
http.ListenAndServe(binding, nil)
}
14 changes: 7 additions & 7 deletions service/storage.go
Expand Up @@ -45,15 +45,15 @@ func (cl *Client) storeFileS3(cj *ConversionJob, filePath string) error {

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Debug("Read file from working directory")
}).Debug("read file from working directory")
data, err := ioutil.ReadFile(filePath)
if err != nil {
return err
}

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Info("Start upload of file to S3")
}).Info("start upload of file to S3")

// Uploads the object to S3 ... the Context will interrupt the request if the
// timeout expires
Expand All @@ -68,19 +68,19 @@ func (cl *Client) storeFileS3(cj *ConversionJob, filePath string) error {
// by a context the CanceledErrorCode error code will be returned
log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Errorf("Upload cancelled due to timeout: %v", err)
}).Errorf("upload cancelled due to timeout: %v", err)
} else {
log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Errorf("Failed to upload file: %v", err)
}).Errorf("failed to upload file: %v", err)
}

return err
}

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Info("Completed upload of file to S3")
}).Info("completed upload of file to S3")

return nil
}
Expand All @@ -95,13 +95,13 @@ func (cl *Client) getFileS3SignedURL(cj *ConversionJob, exp time.Duration) (stri

log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Debugln("Generating pre-signed url to rendered file")
}).Debugln("generating pre-signed url to rendered file")

url, err := req.Presign(exp)
if err != nil {
log.WithFields(log.Fields{
"uuid": cj.Identifier,
}).Error("Failed to pre-sign url")
}).Error("failed to pre-sign url")

return url, err
}
Expand Down

0 comments on commit dafe527

Please sign in to comment.