Skip to content

Commit

Permalink
fix: restore logging in sls plugin, use Tap 18
Browse files Browse the repository at this point in the history
  • Loading branch information
eoinsha committed Oct 31, 2023
1 parent cdbc87d commit 1564b61
Show file tree
Hide file tree
Showing 10 changed files with 13,090 additions and 12,707 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
github-token: ${{ secrets.github_token }}
flag-name: run-node-${{ matrix.node-version }}
parallel: true
path-to-lcov: coverage/lcov.info
path-to-lcov: .tap/report/lcov.info
finish:
needs: build
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ src/

node_modules/
.nyc_output/
.tap/
.serverless/
coverage/
.vscode/
Expand All @@ -258,4 +259,4 @@ lerna-debug*


samconfig.toml
packaged.yaml
packaged.yaml
2 changes: 2 additions & 0 deletions cf-macro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import Ajv from 'ajv'
import pino from 'pino'

import { addAlarms, addDashboard, defaultConfig, slicWatchSchema, getResourcesByType } from '../core/index'
import { setLogger } from 'slic-watch-core/logging'

const logger = pino({ name: 'macroHandler' })
setLogger(logger)

interface Event {
requestId?
Expand Down
4 changes: 2 additions & 2 deletions core/cf-template.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pino from 'pino'
import type Resource from 'cloudform-types/types/resource'
import type Template from 'cloudform-types/types/template'

import { filterObject } from './filter-object'
import { getLogger } from './logging'

const logger = pino()
const logger = getLogger()

export type ResourceType = Record<string, Resource>

Expand Down
4 changes: 2 additions & 2 deletions core/dashboards/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pino from 'pino'
import type { Entries } from 'type-fest'
import type Template from 'cloudform-types/types/template'

Expand All @@ -10,6 +9,7 @@ import type { CreateMetricWidget, DashboardBodyProperties, FunctionDashboardConf
import { findLoadBalancersForTargetGroup } from '../alarms/alb-target-group'
import { resolveRestApiNameForSub } from '../alarms/api-gateway'
import { resolveEcsClusterNameForSub, resolveGraphlQLId, resolveLoadBalancerFullNameForSub, resolveTargetGroupFullNameForSub } from './dashboard-utils'
import { getLogger } from '../logging'

declare global {
interface ObjectConstructor {
Expand All @@ -20,7 +20,7 @@ declare global {

const MAX_WIDTH = 24

const logger = pino()
const logger = getLogger()

/**
* @param {*} dashboardConfig The global plugin dashboard configuration
Expand Down
14 changes: 14 additions & 0 deletions core/logging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pino from 'pino'

let logger

export function setLogger (log) {
logger = log
}

export function getLogger (options = {}) {
if (logger === undefined) {
logger = pino(options)
}
return logger
}
Loading

0 comments on commit 1564b61

Please sign in to comment.