Преглед на файлове

Prepare to release `@converse/log`

JC Brand преди 1 месец
родител
ревизия
0bffe271ca
променени са 3 файла, в които са добавени 68 реда и са изтрити 12 реда
  1. 1 1
      src/headless/package.json
  2. 66 10
      src/log/README.md
  3. 1 1
      src/log/package.json

+ 1 - 1
src/headless/package.json

@@ -58,7 +58,7 @@
     "url": "https://github.com/conversejs/converse.js/issues"
   },
   "dependencies": {
-    "@converse/log": "file:../log",
+    "@converse/log": "^0.0.1",
     "@converse/openpromise": "^0.0.4",
     "@converse/skeletor": "^0.0.9",
     "dayjs": "^1.11.8",

+ 66 - 10
src/log/README.md

@@ -1,25 +1,81 @@
 # @converse/log
 
-A helper module which lets you log messages to the console, with different log levels.
+[![npm version](https://img.shields.io/npm/v/@converse/log.svg)](https://www.npmjs.com/package/@converse/log)
+[![License](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/conversejs/converse.js/blob/master/LICENSE.txt)
 
-Use `log.setLogLevel` to set the log level. All messages with a log level equal
-to or higher than what's set, will be logged to the console.
+A lightweight logging utility for Converse.js and related projects, providing configurable log levels and console output formatting.
+
+## Features
+
+- Multiple log levels (debug, info, warn, error, fatal)
+- Customizable output styling
+- Simple API
+- Zero dependencies
+- TypeScript support
 
 ## Installation
 
 ```bash
 npm install @converse/log
+# or
+yarn add @converse/log
 ```
 
-## Usage
+## Basic Usage
 
 ```javascript
 import log from '@converse/log';
 
-log.setLogLevel('warn');
-log.debug('Debug message'); // This message will NOT be logged
-log.info('Info message'); // This message will NOT be logged
-log.warn('Warning message'); // This message will be logged
-log.error('Error message'); // This message will be logged
-log.fatal('Fatal error'); // This message will be logged
+// Configure log level (default: 'info')
+log.setLogLevel('debug');
+
+// Log messages
+log.debug('Detailed debug information');
+log.info('System status update');
+log.warn('Potential issue detected');
+log.error('Operation failed');
+log.fatal('Critical system failure');
+
+// Log with custom styling
+log.info('Important notice', 'color: blue; font-weight: bold');
+```
+
+## API Reference
+
+### `setLogLevel(level: string): void`
+Sets the minimum log level to display. Available levels (in order of severity):
+- `debug`
+- `info` (default)
+- `warn` 
+- `error`
+- `fatal`
+
+### Logging Methods
+All methods accept an optional `style` parameter for custom console output styling.
+
+- `log.debug(message: string, style?: string): void`
+- `log.info(message: string, style?: string): void`
+- `log.warn(message: string, style?: string): void` 
+- `log.error(message: string, style?: string): void`
+- `log.fatal(message: string, style?: string): void`
+
+### `log.log(message: string, level: string, style?: string): void`
+Generic log method where you specify the level.
+
+## Integration with Converse.js
+
+This package is used internally by Converse.js but can also be used independently in other projects.
+
+## Development
+
+To contribute or run tests locally:
+
+```bash
+git clone https://github.com/conversejs/converse.js.git
+cd src/log
+npm install
 ```
+
+## License
+
+MPL-2.0 © [Converse.js Contributors](https://github.com/conversejs/converse.js/graphs/contributors)

+ 1 - 1
src/log/package.json

@@ -3,7 +3,7 @@
   "version": "0.0.1",
   "description": "Logging utilities for Converse.js",
   "author": "JC Brand <jc@opkode.com>",
-  "license": "MIT",
+  "license": "MPL-2.0",
   "main": "index.js",
   "types": "types/index.d.ts",
   "module": "index.js",