sequelize / sequelize/sequelize
Add option to get log messages pre-split as an object of key => message part
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 30.4k
- Forks
- 4.3k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 68
Description
Issue Creation Checklist
- I understand that my issue will be automatically closed if I don't fill in the requested information
- I have read the contribution guidelines
Feature Description
Describe the feature you'd like to see implemented
As a developer, I need the properties of events to be logged (e.g. executed SQL statements) to be clearly defined so that I don't need to write lots of extra code to process it. Essentially, I would like an event object passed to the logging function that either has named keys (e.g. {'sql': "select ...", 'bindings': [1, 2, 3], 'timing': 3000}) or that decouples the current sql argument into additional function arguments (e.g. function logging(sql, bindings, timing)). The former is preferred since a) it's more backward-compatible and b) makes it easier to incorporate additional properties.
Describe why you would like this feature to be added to Sequelize
The current sql argument passed to the logging function is really three arguments concatenated into one long string: a prefix (e.g. Executed (default)), the actual SQL, and after a ;, the bindings (i.e. replace values) used. Parsing a string to customize logging output is a) very inefficient and b) is extremely brittle as the slightest change to the string passed to the function could break the logging function and even worse this would probably not get caught until runtime (i.e. fail silently). Given that this concerns logging, which is the very thing developers, support, and IT turn to first for trouble shooting, it could lead to a lot of headaches. Best case scenario with the current set up is really messy code that's difficult to read.
Is this feature dialect-specific?
- No. This feature is relevant to Sequelize as a whole.
- Yes. This feature only applies to the following dialect(s):
Would you be willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time and I know how to start.
- Yes, I have the time but I will need guidance.
- No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
- No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in implementing my feature.
Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the logging function callback and its current concatenated SQL argument described in the issue. Determine how logging events expose the SQL, bindings, timing, and prefix without requiring string parsing; done means the supported shape is clearly defined and preserves backward compatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, sql, typescript
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100