Skip to content

Commit ad89073

Browse files
committed
Update README
1 parent 58643f1 commit ad89073

File tree

1 file changed

+72
-20
lines changed

1 file changed

+72
-20
lines changed

README.md

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,42 @@ Logging component of <a href="https://purpleteam-labs.com/" title="purpleteam"><
3131

3232
_PurpleTeam_ logger wraps [`winston`](https://github.com/winstonjs/winston) for [_PurpleTeam_ components](https://github.com/purpleteam-labs/), provides a custom [`signale`](https://github.com/klauscfhq/signale) transport, and is open to be extended with additional transports.
3333

34+
purpleteam-logger is used heavily throughout most of the _PurpleTeam_ projects.
35+
36+
# Contents
37+
38+
* [Install](#install)
39+
* [Usage](#usage)
40+
* [Create a Reusable Logger](#create-a-reusable-logger)
41+
* [Use the Logger](#use-the-logger)
42+
* [Specify Transports](#specify-transports)
43+
* [Use the Logger](#use-the-logger-1)
44+
* [Add more Loggers](#add-more-loggers)
45+
* [API](#api)
46+
* [`init(options)`](#initoptions)
47+
* [`get(['default'])`](#getdefault)
48+
* [`add(catagory, [options])`](#addcatagory-options)
49+
* [Custom Transport Details](#custom-transport-details)
50+
* [Examples](#examples)
51+
* [Contribution](#contribution)
52+
* [License](#license)
53+
54+
3455
## Install
3556

36-
```
57+
```shell
3758
npm install purpleteam-logger
3859
```
3960
## Usage
4061

41-
### Create a reusable logger
62+
### Create a Reusable Logger
4263

4364
Where ever you need a logger:
4465

45-
```
46-
const log = require('purpleteam-logger').init({level: 'debug'});
66+
```javascript
67+
import { init as initLogger } from 'purpleteam-logger';
68+
69+
const log = initLogger({ level: 'debug' });
4770
```
4871
&nbsp;
4972

@@ -63,18 +86,18 @@ a [combined format](https://github.com/winstonjs/winston#combining-formats) (`fo
6386

6487
and finally a `winston.transport.console` transport is added to the `transports` array property of the options object used to create the logger. This could be made more extensible.
6588

66-
### Use the logger
89+
### Use the Logger
6790

68-
```
91+
```javascript
6992
log.info('Server registered.', {tags: ['startup']});
7093
log.info('Server started.', {tags: ['startup']});
71-
...
94+
// ...
7295
log.info('running testJob', {tags: ['app']});
73-
...
96+
// ...
7497
log.notice(`Constructing the cucumber world for session with id "${id}".\n`, {tags: ['world']});
75-
...
98+
// ...
7699
log.notice(`Located element using id="${attackField.name}", and sent keys.`, {tags: ['browser']});
77-
...
100+
// ...
78101
```
79102

80103
In `development`:
@@ -87,24 +110,38 @@ In `production`:
87110

88111
The available log levels are listed [here](https://github.com/winstonjs/winston#logging-levels);
89112

90-
### Specify transport(s)
113+
### Specify Transport(s)
91114

92115
By default the [`winston.transports.Console`](https://github.com/winstonjs/winston/blob/master/lib/winston/transports/console.js) will be used.
93116

94-
```
95-
const log = require('purpleteam-logger').init({level: 'debug', transports: ['Console']});
117+
```javascript
118+
import { init as initLogger } from 'purpleteam-logger';
119+
120+
const log = initLogger({ level: 'debug', transports: ['Console'] });
96121
```
97122

98123
You can specify the name of one or more transport constructors.
99124

100125
Using the [`SignaleTransport`](https://github.com/purpleteam-labs/purpleteam-logger/blob/main/src/transports/signale-transport.js) alone for example looks like the following:
101126

127+
```javascript
128+
import { init as initLogger } from 'purpleteam-logger';
129+
130+
const log = initLogger({ level: 'debug', transports: ['SignaleTransport'] });
102131
```
103-
const log = require('purpleteam-logger').init({level: 'debug', transports: ['SignaleTransport']});
104-
```
105-
### Use the logger
106132

133+
Using the `File` alone for example looks like the following:
134+
135+
```javascript
136+
import { init as initLogger } from 'purpleteam-logger';
137+
138+
const log = initLogger({ level: 'debug', transports: ['File'], filename: '/path/to/your/logfile' });
107139
```
140+
141+
142+
### Use the Logger
143+
144+
```javascript
108145
log.emerg('This is what an emergency looks like.', { tags: ['emerg-tag'] });
109146
log.alert('This is what an alert looks like.', { tags: ['alert-tag'] });
110147
log.crit('This is what a critical event looks like.', { tags: ['crit-tag'] });
@@ -123,12 +160,16 @@ In `production`:
123160

124161
![production log output](https://user-images.githubusercontent.com/2862029/104266785-381bd180-54f5-11eb-98ac-ff82c45a46c1.png)
125162

126-
### Add more loggers
163+
### Add more Loggers
127164

128165
If you want to add extra loggers after the default logger has been `init`ialised. See the [Winston docs](https://github.com/winstonjs/winston/tree/5758752f1a3f5b1bf71b750fc32771bdbd1366ce#working-with-multiple-loggers-in-winston) for more details.
129166

130-
```
131-
const log = require('purpleteam-logger').add('nameForYourNewLogger', { transports: ['File'], filename: '/path/to/your/logfile' });
167+
```javascript
168+
import { init as initLogger } from 'purpleteam-logger';
169+
170+
const log = initLogger({ level: 'debug' });
171+
172+
log.add('nameForYourNewLogger', { transports: ['File'], filename: '/path/to/your/logfile' })
132173
```
133174

134175
&nbsp;
@@ -155,7 +196,7 @@ If you supply an argument that is the name of a logger you have created previous
155196

156197
If no `options` are supplied to `add`, a new `options` object will be created using a transport of [`Console`](https://github.com/winstonjs/winston/blob/5758752f1a3f5b1bf71b750fc32771bdbd1366ce/docs/transports.md#console-transport), and the same `level` that the default logger has.
157198

158-
## Custom transport details
199+
## Custom Transport Details
159200

160201
Currently `signale` is the only custom transport in the project, feel free to add additional transports.
161202
The `signale` types can be seen at:
@@ -165,6 +206,17 @@ The `signale` types can be seen at:
165206

166207
Which utilise [figures](https://github.com/sindresorhus/figures/blob/master/index.js) for icons.
167208

209+
## Examples
210+
211+
There are many examples of how purpleteam-logger is being used in the [purpleteam-labs projects](https://github.com/purpleteam-labs) in both development and production environments. In particular the following projects would be a good place to start:
212+
213+
* [purpleteam (the CLI)](https://github.com/purpleteam-labs/purpleteam)
214+
* [purpleteam-orchestrator](https://github.com/purpleteam-labs/purpleteam-orchestrator)
215+
* [purpleteam-app-scanner](https://github.com/purpleteam-labs/purpleteam-app-scanner)
216+
* [purpleteam-tls-scanner](https://github.com/purpleteam-labs/purpleteam-tls-scanner)
217+
218+
There are also [videos](https://purpleteam-labs.com/videos/) of purpleteam-logger in action.
219+
168220
## Contribution
169221

170222
Please open an [issue](https://github.com/purpleteam-labs/purpleteam/issues) to discus the proposed change before submitting a [pull request](https://github.com/purpleteam-labs/purpleteam-logger/pulls).

0 commit comments

Comments
 (0)