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

loggers #996

Merged
merged 23 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5b42a24
multiple loggers
adrianmroz-allegro Dec 13, 2022
1d7d9ea
simplify routes parameters
adrianmroz-allegro Dec 13, 2022
6e4f26e
pass logger explicitly
adrianmroz-allegro Dec 13, 2022
9846969
use specific loggers in CLI functions
adrianmroz-allegro Dec 13, 2022
c6f05d3
fix test compile error
adrianmroz-allegro Dec 14, 2022
1d39ba9
validate logger format setting
adrianmroz-allegro Dec 14, 2022
9f66e7c
override logger format from CLI parameter
adrianmroz-allegro Dec 14, 2022
b9d429b
use logger on server start
adrianmroz-allegro Dec 14, 2022
f6eec7b
docs typo
adrianmroz-allegro Dec 14, 2022
c0b4dcd
log errors with correct level and in one event
adrianmroz-allegro Dec 14, 2022
68146f1
change signature for readability
adrianmroz-allegro Dec 14, 2022
a6b91cd
fix tests
adrianmroz-allegro Dec 14, 2022
ae617a2
reduce exports from logger.ts - logger should be passed directly, no …
adrianmroz-allegro Dec 14, 2022
495de22
logger that redirects everything to stderr
adrianmroz-allegro Dec 14, 2022
2fb53c8
push loggers further
adrianmroz-allegro Dec 14, 2022
638bc90
utils for now in iso format
adrianmroz-allegro Dec 14, 2022
a6feafe
cleaner Logger API and types
adrianmroz-allegro Dec 14, 2022
1d164a7
rename to @timestamp
adrianmroz-allegro Dec 15, 2022
fe3ecc3
add docs
adrianmroz-allegro Dec 15, 2022
88b0621
let commander.js validate logger format values
adrianmroz-allegro Dec 15, 2022
da3a4b0
util for logging js error objects
adrianmroz-allegro Dec 15, 2022
5b8f97b
refactor for brevity
adrianmroz-allegro Dec 15, 2022
d97135a
readiness error should be logged as warn
adrianmroz-allegro Dec 15, 2022
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 src/server/routes/plywood/plywood.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ export function plywoodRouter(settingsManager: Pick<SettingsManager, "anchorPath
};
res.json(reply);
} catch (error) {
logger.log("error:", error.message);
let message = error.message;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think moving this logic of extracting the message from error, checking if it has the stack property etc. to a helper function could clean up the code a little bit

if (error.hasOwnProperty("stack")) {
logger.log((error as any).stack);
message += `\n ${error.stack}`;
}
logger.error(message);

res.status(500).send({
error: "could not compute",
message: error.message
Expand Down
6 changes: 4 additions & 2 deletions src/server/routes/shorten/shorten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export function shortenRouter(settings: Pick<SettingsManager, "appSettings" | "l
const shortUrl = await shortener(request, url as string, context);
res.json({ shortUrl });
} catch (error) {
logger.log("error:", error.message);
let message = error.message;
if (error.hasOwnProperty("stack")) {
logger.log((error as any).stack);
message += `\n ${error.stack}`;
}
logger.error(message);

res.status(500).send({
error: "could not shorten url",
message: error.message
Expand Down
6 changes: 4 additions & 2 deletions src/server/routes/sources/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export function sourcesRouter(settings: Pick<SettingsManager, "getSources" | "lo
dataCubes: dataCubes.filter( dataCube => checkAccess(dataCube, req.headers) )
}));
} catch (error) {
logger.error(error.message);
let message = error.message;
if (error.hasOwnProperty("stack")) {
logger.error(error.stack);
message += `\n ${error.stack}`;
}
logger.error(message);

res.status(500).send({
error: "Can't fetch settings",
message: error.message
Expand Down