Giter Club home page Giter Club logo

zapdriver's People

Contributors

afirth avatar asahasrabuddhe avatar hermanbanken avatar itaischwartz avatar jeanmertz avatar jrbarron avatar jun06t avatar keesvv avatar mattayes avatar mhindery avatar moricho avatar shivam010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zapdriver's Issues

exception field is missing on sugar logs

Tested using:

func TestStackTrace(t *testing.T) {
	config := NewProductionConfig()
	logger, err := config.Build()
	require.NoError(t, err)
	core, logs := observer.New(zap.InfoLevel)
	logger = logger.WithOptions(zap.WrapCore(func(zapcore.Core) zapcore.Core {
		return core
	}), WrapCore(ReportAllErrors(true)))
	logger.Error("error", zap.Error(errors.New("internal error")))
	logger.Sugar().With(zap.Error(errors.New("internal error"))).Error("error2")

	require.NotEmpty(t, logs.All()[0].ContextMap()["exception"])
	require.NotEmpty(t, logs.All()[1].ContextMap()["exception"])
}

Unable to get module when GOPROXY=direct is specified

Hi. I found a issue that the go.ajitem.com/zapdriver is unable to download when GOPROXY=direct is specified.

❯ GOPROXY=direct go get go.ajitem.com/zapdriver
go: unrecognized import path "go.ajitem.com/zapdriver": https fetch: Get "https://go.ajitem.com/zapdriver?go-get=1": dial tcp 95.111.198.227:443: i/o timeout

Error reporting - empty stacktrace

Hello, I got following code which is deployed on CloudRun.
Version: v1.4.1

        logger, _ := zapdriver.NewProductionWithCore(zapdriver.WrapCore(
		zapdriver.ReportAllErrors(true),
		zapdriver.ServiceName("gcp-test-logging"),
	))

	if err := do(); err != nil {
		logger.Error("do failed", zap.Error(err))
	}

I can see the error in logs and also in error reporting.

Log message

{
  "insertId": "id",
  "jsonPayload": {
    "message": "do failed",
    "stacktrace": "main.main\n\t/workspace/main.go:43\nruntime.main\n\t/layers/google.go.runtime/go/src/runtime/proc.go:250",
    "caller": "workspace/main.go:43",
    "context": {
      "reportLocation": {
        "lineNumber": "43",
        "filePath": "/workspace/main.go",
        "functionName": "main.main"
      }
    },
    "error": "something happened",
    "serviceContext": {
      "service": "gcp-test-logging",
      "version": ""
    },
    "timestamp": "2023-05-26T08:49:53.004139897Z"
  },
  "resource": {
    "type": "cloud_run_revision",
    "labels": {
      "project_id": "project-id",
      "revision_name": "gcp-test-logging-00001-gun",
      "location": "europe-west1",
      "configuration_name": "gcp-test-logging",
      "service_name": "gcp-test-logging"
    }
  },
  "timestamp": "2023-05-26T08:49:53.004352Z",
  "severity": "ERROR",
  "labels": {
    "instanceId": "id"
  },
  "logName": "projects/project-id/logs/run.googleapis.com%2Fstderr",
  "sourceLocation": {
    "file": "/workspace/main.go",
    "line": "43",
    "function": "main.main"
  },
  "receiveTimestamp": "2023-05-26T08:49:53.008681876Z"
}

But sample (raw and also parsed) is empty.

image

Why? it is supported?

Maybe it's fixed in v1.4.2?
But I can't update it

go get -u go.ajitem.com/[email protected]
go: go.ajitem.com/[email protected]: unrecognized import path "go.ajitem.com/zapdriver": parse https://go.ajitem.com/zapdriver?go-get=1: no go-import meta tags ()

go get -u github.com/asahasrabuddhe/zapdriver@latest
go: downloading github.com/asahasrabuddhe/zapdriver v1.4.2
go: github.com/asahasrabuddhe/[email protected]: parsing go.mod:
        module declares its path as: go.ajitem.com/zapdriver
                but was required as: github.com/asahasrabuddhe/zapdriver

Reporting as text instead as json

Hi, I'm trying to migrate from github.com/icco/zapdriver and just replacing import I'm getting mess in logs. Looks like this lib fork is reporting as text instead of structured json for me.

This is how I configure zap

func configureZap() {
	var logger *zap.Logger
	mode := os.Getenv("APP_LOGGING_ENV")

	if mode == "production" {
		config := zapdriver.NewProductionConfig()
		config.Level.SetLevel(getLogLevel())
		l, err := config.Build(
			zapdriver.WrapCore(
				zapdriver.ReportAllErrors(true),
				zapdriver.ServiceName(os.Getenv("K_SERVICE")),
				zapdriver.ServiceVersion(os.Getenv("K_REVISION")),
			),
		)
		if err != nil {
			log.Fatal(err)
		}
		logger = l
	} else {
		if os.Getenv("APP_LOG_PRETTY") == "true" {
			logger = prettyconsole.NewLogger(zap.DebugLevel)
		} else {
			config := zapdriver.NewDevelopmentConfig()
			config.Level.SetLevel(getLogLevel())
			l, err := config.Build(
				zapdriver.WrapCore(
					zapdriver.ReportAllErrors(true),
					zapdriver.ServiceName(os.Getenv("K_SERVICE")),
					zapdriver.ServiceVersion(os.Getenv("K_REVISION")),
				),
			)
			if err != nil {
				log.Fatal(err)
			}
			logger = l
		}
	}
	zap.ReplaceGlobals(logger)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.