Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace console.log with structured logging #508

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b0eb1b4
feat: add in Winston logger and replace console.logs with relevant lo…
LewisBroadhurst Mar 4, 2024
3548464
feat: auto-formatting
LewisBroadhurst Mar 4, 2024
4ab7b53
feat: change folder name to allow logger.js to be committed
LewisBroadhurst Mar 9, 2024
09f5a9e
Fix paths for logger
LewisBroadhurst Mar 28, 2024
f85483a
More logging module path fixes
LewisBroadhurst Mar 28, 2024
3bf39a9
feat: requirement for non ES6 import for logger
LewisBroadhurst Mar 28, 2024
d9d26fb
feat: remove logger from ui
LewisBroadhurst Mar 28, 2024
20637b0
feat: remove logger from ui
LewisBroadhurst Mar 28, 2024
dca1ed4
Merge branch 'main' into structured-logging
LewisBroadhurst Mar 28, 2024
dccdc78
feat: fix up imports and make logger into a module
LewisBroadhurst Mar 29, 2024
ef3cf62
feat: add better formatting to log
LewisBroadhurst Mar 30, 2024
4e443f8
feat: add better formatting to logs
LewisBroadhurst Mar 30, 2024
059e76f
feat: change log filename
LewisBroadhurst Mar 30, 2024
a3b6b67
Merge branch 'main' into structured-logging
LewisBroadhurst Mar 30, 2024
b1c2381
feat: fix more imports
LewisBroadhurst Mar 30, 2024
c707785
feat: test...
LewisBroadhurst Mar 30, 2024
e6a0e51
fix: improvement to logs and fix for 'Unknown logger level: host' error
LewisBroadhurst Mar 30, 2024
d8b538c
fix: remove test file and fix typo
LewisBroadhurst Mar 30, 2024
af52a50
fix: more log import fixing
LewisBroadhurst Mar 30, 2024
9c161c9
fix: linter change
LewisBroadhurst Mar 30, 2024
c955e73
Merge branch 'main' into structured-logging
JamieSlome Apr 5, 2024
6e44a7c
fix: remove console.log from internal tooling
LewisBroadhurst Apr 6, 2024
fcf61a8
fix: remove logger import
LewisBroadhurst Apr 6, 2024
fc6a6f2
Merge branch 'structured-logging' of https://github.com/LewisBroadhur…
LewisBroadhurst Apr 6, 2024
7bfae3a
test: began adding testing for git-proxy.log
LewisBroadhurst Apr 6, 2024
03fbbc7
feat: ...
LewisBroadhurst Apr 6, 2024
9bdaec1
feat: logging func tests
LewisBroadhurst Apr 7, 2024
1a20bf1
feat: logging func tests
LewisBroadhurst Apr 7, 2024
f1d2f4d
Merge branch 'main' into structured-logging
LewisBroadhurst Apr 7, 2024
df48552
feat: combine console/winston logging
LewisBroadhurst Apr 8, 2024
3f1698c
Merge branch 'structured-logging' of https://github.com/LewisBroadhur…
LewisBroadhurst Apr 8, 2024
a885b1b
fix: add logger line
LewisBroadhurst Apr 8, 2024
94499b5
fix: test commit
LewisBroadhurst Apr 8, 2024
eecb957
feat: ...
LewisBroadhurst Apr 8, 2024
dc2672f
chore: remove test commit line
LewisBroadhurst Apr 8, 2024
d7a0c32
chore: remove test commit line
LewisBroadhurst Apr 8, 2024
3dbf6fa
feat: alternative logger with filename
LewisBroadhurst Apr 11, 2024
3b44195
fix: work out how to add filenames into logger without custom wrapper
LewisBroadhurst Apr 23, 2024
8b03c6c
chore: linting
LewisBroadhurst Apr 23, 2024
7ffe660
feat: merge in latest main branch and change console.logs
LewisBroadhurst May 6, 2024
3869f4e
feat: more console.log -> logger.info changes
LewisBroadhurst May 6, 2024
520c5a5
Merge branch 'main' into structured-logging
JamieSlome May 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node
/* eslint-disable max-len */
const { logger } = require('./src/logging/index');

const argv = require('yargs/yargs')(process.argv.slice(2))
.usage('Usage: $0 [options]')
.options({
Expand Down Expand Up @@ -27,7 +29,7 @@ if (argv.v) {
const configFile = require('./src/config/file').configFile;

if (!fs.existsSync(configFile)) {
console.error(
logger.error(
`Config file ${configFile} doesn't exist, nothing to validate! Did you forget -c/--config?`,
);
process.exit(1);
Expand All @@ -40,7 +42,7 @@ if (argv.v) {

validate(config, schema, { required: true, throwError: true });

console.log(`${configFile} is valid`);
logger.info(`${configFile} is valid`);
process.exit(0);
}

Expand Down
3 changes: 2 additions & 1 deletion nyc.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const { logger } = require('./src/logging/index');
const opts = {
branches: 80,
lines: 80,
functions: 80,
statements: 80,
};

console.log('nyc config: ', opts);
logger.info(`nyc config: ${opts}`);
module.exports = opts;
176 changes: 172 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"react-html-parser": "^2.0.2",
"react-router-dom": "6.22.3",
"uuid": "^9.0.0",
"winston": "^3.12.0",
"yargs": "^17.7.2"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/git-proxy-notify-hello/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const Step = require('@finos/git-proxy/src/proxy/actions').Step;
const plugin = require('@finos/git-proxy/src/plugin');
const { logger } = require('../../src/logging/index');

Check warning on line 3 in packages/git-proxy-notify-hello/index.js

View check run for this annotation

Codecov / codecov/patch

packages/git-proxy-notify-hello/index.js#L3

Added line #L3 was not covered by tests

const helloPlugin = new plugin.ActionPlugin(async (req, action) => {
const step = new Step('HelloPlugin');
console.log('This is a message from the HelloPlugin!');
logger.info('This is a message from the HelloPlugin!');

Check warning on line 7 in packages/git-proxy-notify-hello/index.js

View check run for this annotation

Codecov / codecov/patch

packages/git-proxy-notify-hello/index.js#L7

Added line #L7 was not covered by tests
action.addStep(step);
return action;
});
Expand Down
7 changes: 4 additions & 3 deletions scripts/doc-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { execFileSync } = require('child_process');
const { writeFileSync, readFileSync, mkdtempSync } = require('fs');
const { tmpdir } = require('os');
const { sep } = require('path');
const { logger } = require('../src/logging/index');
const JSFH_CONFIG = './jsfh.config.json';
const SCHEMA_FILE = './config.schema.json';
const OUTPUT_PATH = './website/docs/configuration/reference.mdx';
Expand All @@ -17,7 +18,7 @@ try {
SCHEMA_FILE,
`${tempdir}${sep}schema.md`,
]).toString('utf-8');
console.log(genDocOutput);
logger.info(genDocOutput);
LewisBroadhurst marked this conversation as resolved.
Show resolved Hide resolved

const schemaDoc = readFileSync(`${tempdir}${sep}schema.md`, 'utf-8')
.replace(/\n\n<\/summary>/g, '</summary>')
Expand All @@ -30,7 +31,7 @@ description: JSON schema reference documentation for Git Proxy
${schemaDoc}
`;
writeFileSync(OUTPUT_PATH, docString);
console.log(`Wrote schema reference to ${OUTPUT_PATH}`);
logger.info(`Wrote schema reference to ${OUTPUT_PATH}`);
} catch (err) {
console.error(err);
logger.error(err);
LewisBroadhurst marked this conversation as resolved.
Show resolved Hide resolved
}
Loading
Loading