@blockflow-labs/logger
v1.0.1
Published
A logger for just about everything blockflow
Downloads
4
Readme
@blockflow-labs/logger
A flexible and easy-to-use logging library for Blockflow CLI applications.
Installation
You can install this package using npm:
npm install @blockflow-labs/logger
## Usage
Here's a basic example of how to use the logger:
```typescript
import Logger from "@blockflow-labs/logger";
// Create a new logger instance
const logger = new Logger({
level: "debug",
format: "pretty",
useColor: true,
});
// Log messages
logger.info("Application started");
logger.warn("Low memory warning");
logger.error("Failed to connect to database");
logger.debug("Debugging information");
```
### Configuration Options
When creating a new Logger instance, you can pass an options object with the following properties:
- `level`: The minimum level of messages to log. Can be 'error', 'warn', 'info', or 'debug'. Default is 'info'.
- `format`: The output format. Can be 'pretty' or 'json'. Default is 'pretty'.
- `useColor`: Whether to use colors in the output. Default is true.
### Methods
- `error(message: string)`: Log an error message.
- `warn(message: string)`: Log a warning message.
- `info(message: string)`: Log an info message.
- `debug(message: string)`: Log a debug message.
- `setFormat(format: 'json' | 'pretty')`: Change the output format.
- `setUseColor(useColor: boolean)`: Enable or disable colored output.
## Development
To set up the development environment:
1. Clone the repository
2. Install dependencies: `npm install`
3. Run tests: `npm test`
4. Run tests with coverage: `npm run test:coverage`
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the ISC License.