Skip to content

Commit

Permalink
Updated descriptions (#12)
Browse files Browse the repository at this point in the history
* Fixed description.

* Added section for creating handler in README.

* Added configuration values in README.

* Updated README.

* Updated default value of WriteMessageHandlers in readme.

* Updated README.

* Removed TODO from README

* Updated package versions.
  • Loading branch information
GiedriusGrabauskas authored Nov 27, 2017
1 parent b675f30 commit 3ec22b5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 11 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 61,25 @@ const logger = new LoggerBuilder({
});
```

### Creating logger handler

```ts
import { MessageHandlerBase, LogLevel, LoggerBuilder, LoggerConfigurationBuilder } from "simplr-logger";

class MyMessageHandler extends MessageHandlerBase {
public HandleMessage(level: LogLevel, timestamp: number, messages: any[]): void {
console.log(...messages);
}
}

const config = new LoggerConfigurationBuilder()
.AddWriteMessageHandler({ Handler: new MyMessageHandler(), LogLevel: LogLevel.Trace })
.Build();

const logger = new LoggerBuilder(config);

```

### Using logger

#### Logging with methods
Expand Down Expand Up @@ -105,7 124,15 @@ logger.UpdateConfiguration(builder => builder.SetPrefix("[new prefix]").Build(),
| Debug | 16 | Logs that are used for interactive investigation during development. These logs should primarily contain information useful for debugging and have no long-term value. |
| Trace | 32 | Logs that contain the most detailed messages. These messages may contain sensitive application data. These messages are disabled by default and should never be enabled in a production environment. |

TODO
### Configuration

| Name | Default value | Description |
|-----------------------|----------------------------------------------------------------------------|--------------------------------------------------------------------|
| WriteMessageHandlers | `[{ Handler: new ConsoleMessageHandler() }]` | Message handlers list. ⁽¹⁾ |
| DefaultLogLevel | `{ LogLevel: LogLevel.Warning, LogLevelIsBitMask: false }` | Log level or log levels in bit mask value. |
| Prefix | `undefined` | Custom message, which will be injected into the start of messages. |

`(1)` - The default value is only available if configuration property is not set.

## License

Expand Down
20 changes: 13 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 56,7 @@
},
"homepage": "https://github.com/SimplrJS/simplr-logger#readme",
"devDependencies": {
"@types/jest": "^21.1.7",
"@types/jest": "^21.1.8",
"@types/node": "^8.0.53",
"coveralls": "^3.0.0",
"jest": "^21.2.1",
Expand All @@ -66,7 66,7 @@
"ts-loader": "^3.1.1",
"tslint": "^5.8.0",
"typescript": "^2.6.1",
"uglify-js": "^3.1.9",
"uglify-js": "^3.2.0",
"webpack": "^3.8.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/builders/logger-configuration-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 59,7 @@ export class LoggerConfigurationBuilder {
* Add a list of write message handlers.
*
* @param handlers Write message handlers list.
* @param defaultLogLevel Default log level only for this list of handler.
* @param defaultLogLevel Default log level only for this list of handlers.
*/
public AddWriteMessageHandlers(handlers: WriteMessageHandlerBuilder[], defaultLogLevel?: LogLevel | LogLevel[]): this {
if (defaultLogLevel != null) {
Expand Down

0 comments on commit 3ec22b5

Please sign in to comment.