@shushed/helpers 0.0.59 → 0.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
  import { DeepRedact } from '@hackylabs/deep-redact';
3
3
  import { Firestore, DocumentReference } from '@google-cloud/firestore';
4
+ import { Logging as Logging$1 } from '@google-cloud/logging';
4
5
  import { PubSub, Topic, Subscription } from '@google-cloud/pubsub';
5
6
  import { Context } from 'co-body';
6
7
  import * as _google_cloud_scheduler_build_protos_protos from '@google-cloud/scheduler/build/protos/protos';
@@ -28783,6 +28784,10 @@ declare class Logging implements ILogging {
28783
28784
  private workflowId;
28784
28785
  private triggerId;
28785
28786
  private systemEnvName;
28787
+ gcpLogging: Logging$1;
28788
+ metadata: any;
28789
+ logFn: (...args: any[]) => void;
28790
+ errorFn: (...args: any[]) => void;
28786
28791
  constructor(workflowId: string, triggerId: string, systemEnvName: string);
28787
28792
  log(...args: any[]): void;
28788
28793
  error(...args: any[]): void;
package/dist/index.js CHANGED
@@ -363,15 +363,41 @@ var import_crypto = __toESM(require("crypto"));
363
363
  var import_jose = require("jose");
364
364
 
365
365
  // src-public/runtime.ts
366
+ var import_logging = require("@google-cloud/logging");
366
367
  var DEFAULT_BRANCH = "migratedprod";
367
368
  var Logging = class {
368
369
  constructor(workflowId, triggerId, systemEnvName) {
369
370
  this.workflowId = workflowId;
370
371
  this.triggerId = triggerId;
371
372
  this.systemEnvName = systemEnvName;
373
+ this.gcpLogging = new import_logging.Logging({ projectId: process.env.GCLOUD_PROJECT });
374
+ this.metadata = {
375
+ resource: { type: "cloud_run_revision" },
376
+ labels: {
377
+ project_id: process.env.GCLOUD_PROJECT
378
+ }
379
+ };
380
+ if (process.env.GCLOUD_PROJECT && process.env.RUNTIME_URL) {
381
+ const log = this.gcpLogging.log(`projects/${process.env.GCLOUD_PROJECT}/logs/rowy-logging`, {
382
+ removeCircular: true
383
+ });
384
+ this.logFn = (...args) => log.entry(Object.assign({
385
+ severity: import_logging.Severity.info
386
+ }, this.metadata), ...args);
387
+ this.errorFn = (...args) => log.entry(Object.assign({
388
+ severity: import_logging.Severity.error
389
+ }, this.metadata), ...args);
390
+ } else {
391
+ this.logFn = console.log;
392
+ this.errorFn = console.error;
393
+ }
372
394
  }
395
+ gcpLogging;
396
+ metadata;
397
+ logFn;
398
+ errorFn;
373
399
  log(...args) {
374
- console.log({
400
+ this.logFn({
375
401
  payload: args,
376
402
  workflowId: this.workflowId,
377
403
  wId: this.workflowId,
@@ -381,7 +407,7 @@ var Logging = class {
381
407
  });
382
408
  }
383
409
  error(...args) {
384
- console.error({
410
+ this.errorFn({
385
411
  payload: args,
386
412
  workflowId: this.workflowId,
387
413
  wId: this.workflowId,
package/dist/package.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "license": "UNLICENSED",
6
6
  "description": "",
7
7
  "dependencies": {
8
+ "@google-cloud/logging": "^11.2.0",
8
9
  "@hackylabs/deep-redact": "^2.2.1",
9
10
  "ajv": "^8.17.1",
10
11
  "ajv-formats": "^3.0.1",
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",
7
7
  "dependencies": {
8
+ "@google-cloud/logging": "^11.2.0",
8
9
  "@hackylabs/deep-redact": "^2.2.1",
9
10
  "ajv": "^8.17.1",
10
11
  "ajv-formats": "^3.0.1",