apsystole / log Goto Github PK
View Code? Open in Web Editor NEWGo logging library for GCP App Engine, Cloud Run, Cloud Functions
License: MIT License
Go logging library for GCP App Engine, Cloud Run, Cloud Functions
License: MIT License
This may be out of scope, but I think it would be useful to report errors via a new method, like Report
or something.
Especially because the error detection for Go does not seem to work (compared to e.g. NodeJS) – it logs panics but usually does not report them to error reporting automatically.
Some info:
https://cloud.google.com/error-reporting/docs/formatting-error-messages
json @type needs to be type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.github/workflows/golangci-lint.yml
actions/checkout v4
golangci/golangci-lint-action v4
.github/workflows/gotest.yml
actions/setup-go v5
actions/checkout v4
actions/setup-go v5
actions/checkout v4
actions/setup-go v5
actions/checkout v4
actions/setup-go v5
actions/checkout v4
ubuntu 22.04
go.mod
go 1.11
This may be out of scope, but I was thinking if the logs could maybe render more beautiful locally. Instead of this, which looks not very readable:
{"message":"asdf","severity":"CRITICAL","Field":"sup"}
{"message":"asdf","severity":"INFO"}
{"message":"asdf","severity":"ERROR"}
{"message":"asdf","severity":"ALERT"}
First, it would be nice if locally there would be no escape characters displayed:
Second, I am thinking if this would be more useful to log locally (one could check if some env var is set, like an automatically set in cloud run /k8s or a custom one):
⚠️ asdf
❌ asdf
❗ asdf { "Field": "sup" }
The stdlib defaults to escaping some chars inside JSON, not for any JSON-related reasons, but to protect... HTML? Huh.
Better to disable it:
package main
import (
"fmt"
"encoding/json"
"bytes"
)
func main() {
data := "x < y"
raw,_ := json.Marshal(data)
fmt.Println(string(raw))
//prints: "x \u003c y" <- probably not what you expected
var b1 bytes.Buffer
json.NewEncoder(&b1).Encode(data)
fmt.Println(b1.String())
//prints: "x \u003c y" <- probably not what you expected
var b2 bytes.Buffer
enc := json.NewEncoder(&b2)
enc.SetEscapeHTML(false)
enc.Encode(data)
fmt.Println(b2.String())
//prints: "x < y" <- looks better
}
Visit https://cloud.google.com/functions/docs/concepts/go-runtime and see what OS and Go versions they use. This might change over time, but this library should be tested to work against the very same versions. Verify if the versions match the contents of .github/workflows/gotest.yml
under the section gcp_cloud_functions_exact
, because this is what is continuously tested during development.
Leave a comment in this issue saying if the version match (yes/no), but do not close the issue; this task is perennial 😒 If the versions do not match, the yml needs an update. Please create such update as a normal pull request against the master
branch.
Thanks a lot for this package.
I have a question tho, what do I have to do so that errors are reported to Google Error Reporting? It seems like the stacktrace is missing for that, but I may be wrong.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.