lifadev / archive_aws-lambda-go

A fast and clean way to execute Go on AWS Lambda.
https://github.com/eawsy/aws-lambda-go
Apache License 2.0
699 stars 36 forks source link

SIGSEGV when calling log package locally #6

Closed alexandernilsson closed 7 years ago

alexandernilsson commented 7 years ago

I started playing around with this package, but when writing test and running them locally the process dies with a SIGSEGV as soon as the log package is called.

Would it be possible to only override the log package when running in AWS Lambda, and logging normally during runs outside of it?

fsenart commented 7 years ago

Hi,

As we use the vanilla Go log package and more precisely its singleton version. You are free to reset the output writer. Here is an example:

package main

import (
    "fmt"
    "log"
    "testing"
)

type mockLogger struct{}

func (l *mockLogger) Write(info []byte) (int, error) {
    fmt.Printf(string(info))
    return len(info), nil
}

func TestHandle(*testing.T) {
    log.SetOutput(&mockLogger{})
    handle(nil, nil)
}

Does this suit your needs?

alexandernilsson commented 7 years ago

Yes, that works!

This might be a good thing to put in the README in case someone else runs into it?

lion3ls commented 7 years ago

Good to know :smile:.

As you suggest, we will update README ASAP.

Enjoy playing :jack_o_lantern: