Skip to content

Commit

Permalink
Merge pull request #3347 from thematters/feat/refine-logging
Browse files Browse the repository at this point in the history
feat: refine logging
  • Loading branch information
gary02 authored May 16, 2023
2 parents 746f5fa + f190c9f commit bafdee1
Show file tree
Hide file tree
Showing 79 changed files with 487 additions and 560 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
MATTERS_ENV=local
MATTERS_LOGGING_LEVEL=info
MATTERS_DEBUG=queue,service-article
MATTERS_SERVER_DOMAIN=localhost:4000
MATTERS_SITE_DOMAIN=localhost:3000
MATTERS_OAUTH_SITE_DOMAIN=localhost:3000
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
env:
CODECOV_TOKEN: de5ab681-0837-4a24-b614-0a29225a7e4c
MATTERS_ENV: test
MATTERS_LOGGING_LEVEL: warn
MATTERS_PG_HOST: localhost
MATTERS_PG_USER: postgres
MATTERS_PG_PASSWORD: postgres
Expand Down
8 changes: 4 additions & 4 deletions db/globalTestSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const user = process.env['MATTERS_PG_USER']
const password = process.env['MATTERS_PG_PASSWORD']

// https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
const isCI = !!process.env['CI']
const debug = process.env['MATTERS_LOGGING_LEVEL'] === 'debug'

global.knex = knex

Expand Down Expand Up @@ -79,11 +79,11 @@ async function runShellDBRollup() {
const sh = spawn('sh', ['-xc', cmd], { cwd, env })

sh.stdout.on('data', (data) => {
if (isCI) console.log(`stdout: ${data}`)
if (debug) console.log(`stdout: ${data}`)
})

sh.stderr.on('data', (data) => {
if (isCI) console.log(`stderr: ${data}`)
if (debug) console.log(`stderr: ${data}`)
})

sh.on('error', (error) => {
Expand All @@ -92,7 +92,7 @@ async function runShellDBRollup() {
})

sh.on('close', (code) => {
if (isCI) console.log(`child process exited with code ${code}`)
if (debug) console.log(`child process exited with code ${code}`)
fulfilled()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ exports.up = async (knex) => {

const temp = await knex(source).from(querySource.as('source')).count().first()
const count = parseInt(temp ? temp.count : '0', 10)
console.log('source count', count)

// migrate
await knex.raw(`
Expand All @@ -32,7 +31,6 @@ exports.up = async (knex) => {
// get total count of migrated records
const result = await knex(target).count().first()
const check = parseInt(result ? result.count : '0', 10)
console.log('migrated count', check)
}

exports.down = async (knex) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ exports.up = async (knex) => {
GROUP BY
article.id
`)
console.log('created drafts.')

// Update `draft_id` of articles
await knex.raw(`
Expand All @@ -94,7 +93,6 @@ exports.up = async (knex) => {
WHERE
article.id = draft_article.article_id
`)
console.log('updated articles.')
}

exports.down = async (knex) => {}
1 change: 0 additions & 1 deletion db/migrations/20210519080506_payout_country.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ exports.up = async (knex) => {
capabilities_transfers: true,
})
if (!accounts || accounts.length <= 0) {
console.log('Payout accounts not found')
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ exports.up = async (knex) => {
.where({ provider: 'stripe' })
.whereIn('state', ['active', 'trialing'])
if (!subs || subs.length <= 0) {
console.log(`${envLabel} subscriptions not found`)
return
}

Expand Down
1 change: 0 additions & 1 deletion db/migrations/20210721140245_auto_follow_matty_tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ exports.up = async (knex) => {
.first()

if (!matty) {
console.log('matty not found')
return
}

Expand Down
Loading

0 comments on commit bafdee1

Please sign in to comment.