-
Notifications
You must be signed in to change notification settings - Fork 59
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
feat: trace level logging #437
Conversation
src/common/log.ts
Outdated
|
||
import through2 = require('through2') | ||
const logStream = through2() | ||
logStream.pipe(process.stdout) | ||
|
||
// TODO: Not clear why I needed this, but got a | ||
// TypeScript error without it. | ||
export interface ConnectorLogger extends riverpig.Logger { } | ||
export class ConnectorLogger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could extend riverpig.Logger and add only the trace
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The riverpig.Logger that is exported is a type alias, rather than a class. It doesn't appear to export its own Logger class. I think extending this will still require me to define a class that fits the extended type definition
src/common/log.ts
Outdated
} | ||
|
||
trace (...msg): void { | ||
this.tracer(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be this.tracer(...msg)
?
this.river.debug(msg, ...elements) | ||
} | ||
|
||
trace (msg: any, ...elements: any[]): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why require two arguments instead of doing just (...msg: any[])
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript is enforcing that the function calls here match the function signatures for their interfaces. Both debug and riverpig implement their logging functions like this, so they expect at least one argument and using just the rest parameter will cause it to complain that it got at least 0 args on compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a comment about this for others who might have the same question?
@@ -1,15 +1,44 @@ | |||
import * as riverpig from 'riverpig' | |||
import { LoggerConfig } from 'riverpig' | |||
import { Logger } from 'riverpig' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be one statement, import { LoggerConfig, Logger } from 'riverpig'
or am I missing something here?
this.river.debug(msg, ...elements) | ||
} | ||
|
||
trace (msg: any, ...elements: any[]): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a comment about this for others who might have the same question?
No description provided.