
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@starbemtech/star-logger
Advanced tools
A TypeScript logging module using Winston and MongoDB, enabling easy integration of logging functionalities into your Node.js microservices. It offers configurable log levels, custom formats, and saves logs to MongoDB, facilitating centralized logging and
Welcome to My Logger, a Node.js module written in TypeScript that simplifies implementing logging in your microservices. It utilizes Winston for log management and MongoDB as the storage destination.
You can install the module via NPM:
$ yarn add star-logger
Import the module and initialize the logger by passing the MongoDB URI and optionally the desired configurations:
import { getLogger } from 'my-logger'
const logger = getLogger('mongodb://localhost:27017/my-database', {
level: 'info',
collection: 'logs',
})
// Using the logger
logger.info('Server started successfully')
logger.warn('High memory usage detected')
logger.error('Failed to connect to the database')
The getLogger function accepts two parameters:
1. mongoUri: string - The MongoDB connection URI.
2. options: LoggerOptions (optional) - An object with configuration options.
Property | Type | Default | Description |
---|---|---|---|
level | string | 'info' | Minimum severity level of logs to be recorded. |
collection | string | 'logs' | Name of the MongoDB collection where logs will be stored. |
mongoOptions | MongoDBConnectionOptions | {} | Additional options for the MongoDB connection. |
import { getLogger } from 'my-logger'
const logger = getLogger('mongodb://localhost:27017/my-database')
// Using the logger
logger.info('Server initialized')
logger.warn('Potential issue detected')
logger.error('An error occurred')
import { getLogger } from 'my-logger'
const logger = getLogger('mongodb://localhost:27017/my-database', {
level: 'debug',
collection: 'my-logs',
mongoOptions: {
authSource: 'admin',
ssl: true,
},
})
// Using the logger
logger.debug('Variable X has value:', x)
To capture uncaught exceptions and ensure they are logged:
import { getLogger } from 'my-logger'
import { transports } from 'winston'
const logger = getLogger('mongodb://localhost:27017/my-database')
// Configure to capture exceptions
logger.exceptions.handle(
new transports.Console(),
new transports.MongoDB({
db: 'mongodb://localhost:27017/my-database',
collection: 'exceptions',
})
)
// Application code
process.on('unhandledRejection', (reason) => {
throw reason
})
You can customize the log format or add new transports as needed.
import { getLogger } from 'my-logger'
import { format } from 'winston'
const customFormat = format.printf(({ level, message, timestamp }) => {
return `${timestamp} [${level.toUpperCase()}]: ${message}`
})
const logger = getLogger('mongodb://localhost:27017/my-database', {
level: 'info',
})
logger.format = format.combine(format.timestamp(), customFormat)
// Using the logger
logger.info('Message with custom format')
import { getLogger } from 'my-logger'
import { transports } from 'winston'
const logger = getLogger('mongodb://localhost:27017/my-database')
// Adding a new file transport
logger.add(new transports.File({ filename: 'combined.log' }))
// Using the logger
logger.info('This log will be saved in MongoDB and the file')
The module includes unit tests written with Jest to ensure reliability.
First, install the development dependencies:
$ yarn
Then, run the tests:
$ yarn test
Ensure that all resources are properly closed after tests to prevent Jest from hanging. This includes:
• Closing Winston logger transports
• Closing MongoDB connections
• Stopping the in-memory MongoDB server used in tests
Contributions are welcome! Feel free to open issues or pull requests on the project’s repository.
Steps to Contribute
1. Fork the project.
2. Create a new branch with your feature or fix: git checkout -b my-feature.
3. Commit your changes: git commit -m 'Add new feature'.
4. Push to the branch: git push origin my-feature.
5. Open a pull request on GitHub.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A TypeScript logging module using Winston and MongoDB, enabling easy integration of logging functionalities into your Node.js microservices. It offers configurable log levels, custom formats, and saves logs to MongoDB, facilitating centralized logging and
The npm package @starbemtech/star-logger receives a total of 4 weekly downloads. As such, @starbemtech/star-logger popularity was classified as not popular.
We found that @starbemtech/star-logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.