Remove GAE logging
This commit is contained in:
@ -40,12 +40,6 @@ export default function createServer() {
|
||||
app.use(cors());
|
||||
app.use(express.static('public', { maxAge: '1y' }));
|
||||
|
||||
// Special startup request from App Engine
|
||||
// https://cloud.google.com/appengine/docs/standard/nodejs/how-instances-are-managed
|
||||
app.get('/_ah/start', (req, res) => {
|
||||
res.status(200).end();
|
||||
});
|
||||
|
||||
app.use(requestLog);
|
||||
|
||||
app.get('/', serveMainPage);
|
||||
|
@ -1,55 +1,10 @@
|
||||
import util from 'util';
|
||||
|
||||
// https://cloud.google.com/appengine/docs/standard/nodejs/runtime#environment_variables
|
||||
const projectId = process.env.GOOGLE_CLOUD_PROJECT;
|
||||
|
||||
const enableDebugging = process.env.DEBUG != null;
|
||||
|
||||
function noop() {}
|
||||
|
||||
function createLog(req) {
|
||||
const traceContext = req.headers['x-cloud-trace-context'];
|
||||
|
||||
if (projectId && traceContext) {
|
||||
const [traceId, spanId] = traceContext.split('/');
|
||||
const trace = `projects/${projectId}/traces/${traceId}`;
|
||||
|
||||
return {
|
||||
debug: enableDebugging
|
||||
? (format, ...args) => {
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
severity: 'DEBUG',
|
||||
'logging.googleapis.com/trace': trace,
|
||||
'logging.googleapis.com/spanId': spanId,
|
||||
message: util.format(format, ...args)
|
||||
})
|
||||
);
|
||||
}
|
||||
: noop,
|
||||
info: (format, ...args) => {
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
severity: 'INFO',
|
||||
'logging.googleapis.com/trace': trace,
|
||||
'logging.googleapis.com/spanId': spanId,
|
||||
message: util.format(format, ...args)
|
||||
})
|
||||
);
|
||||
},
|
||||
error: (format, ...args) => {
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
severity: 'ERROR',
|
||||
'logging.googleapis.com/trace': trace,
|
||||
'logging.googleapis.com/spanId': spanId,
|
||||
message: util.format(format, ...args)
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
debug: enableDebugging
|
||||
? (format, ...args) => {
|
||||
|
@ -1,7 +1,3 @@
|
||||
if (process.env.GAE_ENV === 'standard') {
|
||||
require('@google-cloud/trace-agent').start();
|
||||
}
|
||||
|
||||
import createServer from './createServer.js';
|
||||
|
||||
const server = createServer();
|
||||
|
Reference in New Issue
Block a user