Skip to content

Instantly share code, notes, and snippets.

@philsch
philsch / index.js
Last active October 2, 2022 14:50
gcloud log example three
const functions = require('@google-cloud/functions-framework');
functions.http('test_three', async (req, res) => {
// Writes some log entries
console.log(JSON.stringify({severity: 'INFO', message: 'info log'}));
console.log(JSON.stringify({severity: 'WARNING', message: 'warn log'}));
console.log(JSON.stringify({severity: 'ERROR', message: 'error log'}));
console.log(JSON.stringify({
severity: 'ERROR',
message: new Error('js error').stack
@philsch
philsch / index.js
Last active October 2, 2022 14:18
gcloud log example two
const functions = require('@google-cloud/functions-framework');
// Imports the Google Cloud client library
const {Logging} = require('@google-cloud/logging');
functions.http('test_two', async (req, res) => {
// Init Logging and set current context
const logging = new Logging();
await logging.setProjectId();
await logging.setDetectedResource();
@philsch
philsch / index.js
Last active October 2, 2022 09:47
gcloud log example one
const functions = require('@google-cloud/functions-framework');
const bunyan = require('bunyan');
// Imports the Google Cloud client library for Bunyan
const {LoggingBunyan} = require('@google-cloud/logging-bunyan');
// Creates a Bunyan Cloud Logging client
const loggingBunyan = new LoggingBunyan();
// Create a Bunyan logger that streams to Cloud Logging
> mysql -hlocalhost --protocol=TCP -u root --password=test testdb < seed-test-data.sql
> mysql -hlocalhost --protocol=TCP -u root -p
mysql> SELECT * FROM testdb.users;
+----+-------------+
| id | name |
+----+-------------+
| 1 | Jon Doe |
| 2 | Mr Anderson |
-- MySQL dump 10.13 Distrib 8.0.25, for macos11 (x86_64)
--
-- Host: 127.0.0.1 Database: testdb
-- ------------------------------------------------------
-- Server version 8.0.27
--
-- Table structure for table `users`
--
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| testdb |
+--------------------+
> mysql -h localhost --protocol=TCP -u root -p
Enter password:
mysql>
version: '3.3'
services:
db:
image: mysql/mysql-server:8.0
restart: always
environment:
MYSQL_DATABASE: 'testdb'
MYSQL_ROOT_PASSWORD: 'test'
MYSQL_ROOT_HOST: '%'
> docker composer -v
Docker version 20.10.8, build 3967b7d
const { ApolloServer, gql } = require('apollo-server');
const {GraphQLErrorTrackingExtension} = require('graphql-error-tracking-extension');
const {ErrorReporting} = require('@google-cloud/error-reporting');
const errorReporting = new ErrorReporting();
/*
* ----------------------------------------
* Let's define some custom errors
* ----------------------------------------
*/