-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
New DebugLogger #1302
New DebugLogger #1302
Conversation
src/logger/DebugLogger.ts
Outdated
@@ -0,0 +1,103 @@ | |||
import * as debug from "debug"; |
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.
we need to dynamically load any third-party package using require
from PlatformTools
class. Its requirement for typeorm to be cross-platform
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.
import * as path from "path";
/**
* Platform-specific tools.
*/
export class PlatformTools {
...
/**
* Debug module needed by DebugLogger
*/
static debug = debug;
}
like that? what do you prefer?
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.
no, just see how many other libraries like mkdirp, redis, mysql, etc. are loaded using PlatformTools, its dynamic loading using require
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.
ahh you meant PlatformTools.load
src/logger/DebugLogger.ts
Outdated
private debugInfo = debug("typeorm:info"); | ||
private debugWarn = debug("typeorm:warn"); | ||
|
||
constructor() { |
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.
remove it
src/logger/DebugLogger.ts
Outdated
*/ | ||
export class DebugLogger implements Logger { | ||
private debugQuery = debug("typeorm:query"); | ||
private debugQueryError = debug("typeorm:queryError"); |
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.
typeorm:queryError
queryError looks rough, is there naming convention in debug
? Maybe better name it typeorm:query:error
or typeorm:query-error
?
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.
Thank you for your contribution, can you please update documentation and changelog for the next version as well |
what is the next version number? |
0.1.8 |
maybe we can change
and
|
Motivation
The debug package is the 9th most dependent package, it's used by express, koa, yeoman, babel, mocha, socket.io, eslint, morgan and more. It works in both node.js and browser.
#634 #633
What's new
ConnectOptions.logger
has new value"debug"
Drawbacks
ConnectOptions.logging?: LoggerOptions
is no longer used.You need set env variable
DEBUG=typeorm:*
or calldebug.enable('typeorm:*');
in order to set log level.Benefits
DEBUG=*
andlogger: "debug"
.Example
Here's rest api example, I got a get request and then it reports which query TypeORM executed.
Discussion
logging
option and control everything via debug lib. That's basically how express does logging.