-
-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doghouse: try cloud.google.com/go/logging
- Loading branch information
1 parent
e696428
commit 3571cb2
Showing
5 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package logger | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"net/http" | ||
"os" | ||
|
||
"cloud.google.com/go/logging" | ||
) | ||
|
||
var lg *logging.Logger | ||
|
||
// Init initizlize global logger for doghouse (reviewdog app server). | ||
func Init(ctx context.Context) (close func() error) { | ||
client, err := logging.NewClient(ctx, os.Getenv("GOOGLE_CLOUD_PROJECT")) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
lg = client.Logger("reviewdog-global-logger") | ||
return client.Close | ||
} | ||
|
||
// LogWithReq logs message associated with given HTTP request. | ||
func LogWithReq(r *http.Request, msg string) { | ||
lg.Log(logging.Entry{ | ||
HTTPRequest: &logging.HTTPRequest{Request: r}, | ||
Payload: msg, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters