Commit d821e160 authored by Mo Firouz's avatar Mo Firouz
Browse files

Update zap to latest. Add --logtostdout option. Merged #61

parent ae0c8041
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -4,6 +4,13 @@ All notable changes to this project are documented below.
The format is based on [keep a changelog](http://keepachangelog.com/) and this project uses [semantic versioning](http://semver.org/).

## [Unreleased]
### Added
- Added `--logtostdout` command line flag to redirect log output to terminal.

### Changed
- Updated Zap logging library to latest stable version.
- Command line `--verbose` flag no longer alters the logging output to print to both terminal and file.
- Log output format is set to JSON.

## [0.12.1] - 2017-03-28
### Added
+8 −7
Original line number Diff line number Diff line
@@ -20,24 +20,25 @@ import (
	"encoding/json"
	"flag"
	"fmt"
	"github.com/gorhill/cronexpr"
	"github.com/satori/go.uuid"
	"github.com/uber-go/zap"
	"net/url"
	"os"

	"github.com/gorhill/cronexpr"
	"github.com/satori/go.uuid"
	"go.uber.org/zap"
)

type adminService struct {
	DSNS   string
	logger zap.Logger
	logger *zap.Logger
}

func AdminParse(args []string, logger zap.Logger) {
func AdminParse(args []string, logger *zap.Logger) {
	if len(args) == 0 {
		logger.Fatal("Admin requires a subcommand. Available commands are: 'create-leaderboard'.")
	}

	var exec func([]string, zap.Logger)
	var exec func([]string, *zap.Logger)
	switch args[0] {
	case "create-leaderboard":
		exec = createLeaderboard
@@ -49,7 +50,7 @@ func AdminParse(args []string, logger zap.Logger) {
	os.Exit(0)
}

func createLeaderboard(args []string, logger zap.Logger) {
func createLeaderboard(args []string, logger *zap.Logger) {
	var dsns string
	var id string
	var authoritative bool
+7 −7
Original line number Diff line number Diff line
@@ -18,15 +18,15 @@ import (
	"database/sql"
	"flag"
	"fmt"
	"math"
	"net/url"
	"os"
	"time"

	"math"
	"nakama/build/generated/migration"

	"github.com/rubenv/sql-migrate"
	"github.com/uber-go/zap"
	"go.uber.org/zap"
)

const (
@@ -44,12 +44,12 @@ type statusRow struct {
type migrationService struct {
	DSNS       string
	Limit      int
	logger     zap.Logger
	logger     *zap.Logger
	migrations *migrate.AssetMigrationSource
	db         *sql.DB
}

func MigrationStartupCheck(logger zap.Logger, db *sql.DB) {
func MigrationStartupCheck(logger *zap.Logger, db *sql.DB) {
	migrate.SetTable(migrationTable)
	ms := &migrate.AssetMigrationSource{
		Asset:    migration.Asset,
@@ -67,14 +67,14 @@ func MigrationStartupCheck(logger zap.Logger, db *sql.DB) {

	diff := len(migrations) - len(records)
	if diff > 0 {
		logger.Warn("DB schema outdated, run `nakama migrate up`", zap.Object("migrations", diff))
		logger.Warn("DB schema outdated, run `nakama migrate up`", zap.Int("migrations", diff))
	}
	if diff < 0 {
		logger.Warn("DB schema newer, update Nakama", zap.Object("migrations", int64(math.Abs(float64(diff)))))
		logger.Warn("DB schema newer, update Nakama", zap.Int64("migrations", int64(math.Abs(float64(diff)))))
	}
}

func MigrateParse(args []string, logger zap.Logger) {
func MigrateParse(args []string, logger *zap.Logger) {
	if len(args) == 0 {
		logger.Fatal("Migrate requires a subcommand. Available commands are: 'up', 'down', 'redo', 'status'.")
	}
+18 −4
Original line number Diff line number Diff line
hash: d332790eaf0dd90a5d91b4fddfd82897055e261ff360d616cf363c0e689ab4f6
updated: 2017-03-10T18:12:22.221261057Z
hash: 150ab75d51b17b2fb2b097193ea43bac8e07dfcb8ce0905c115be7e71639f506
updated: 2017-04-13T23:43:22.128299698+01:00
imports:
- name: github.com/armon/go-metrics
  version: 97c69685293dce4c0a2d0b19535179bbc976e4d2
@@ -12,10 +12,11 @@ imports:
- name: github.com/go-gorp/gorp
  version: 4deece61034873cb5b5416e81abe4cea7bd0da72
- name: github.com/go-yaml/yaml
  version: a5b47d31c556af34a302ce5d659e6fea44d90de0
  version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
- name: github.com/gogo/protobuf
  version: 909568be09de550ed094403c2bf8a261b5bb730a
  subpackages:
  - jsonpb
  - proto
- name: github.com/golang/protobuf
  version: 8ee79997227bf9b34611aee7946ae64735e6fd93
@@ -42,7 +43,20 @@ imports:
- name: github.com/uber-go/atomic
  version: 3b8db5e93c4c02efbc313e17b2e796b0914a01fb
- name: github.com/uber-go/zap
  version: a5783ee4b216a927da8f839c45cfbf9d694e1467
  version: a2773be06b9ac7c318a3a105b5c310af5730c6b4
  subpackages:
  - zapcore
- name: go.uber.org/atomic
  version: 4e336646b2ef9fc6e47be8e21594178f98e5ebcf
- name: go.uber.org/zap
  version: a2773be06b9ac7c318a3a105b5c310af5730c6b4
  subpackages:
  - buffer
  - internal/bufferpool
  - internal/color
  - internal/exit
  - internal/multierror
  - zapcore
- name: golang.org/x/crypto
  version: f6b343c37ca80bfa8ea539da67a0b621f84fab1d
  subpackages:
+4 −2
Original line number Diff line number Diff line
@@ -31,8 +31,10 @@ import:
- package: github.com/go-yaml/yaml
  version: v2
- package: github.com/armon/go-metrics
- package: github.com/uber-go/zap
- package: github.com/uber-go/atomic
- package: go.uber.org/zap
  version: ~1.1.0
- package: go.uber.org/atomic
  version: ~1.2.0
- package: github.com/satori/go.uuid
- package: github.com/dgrijalva/jwt-go
  version: ~3.0.0
Loading