Skip to content

Commit aa46174

Browse files
committed
add information describing TS and ES6 usage
1 parent afbe1ef commit aa46174

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,66 @@ The DailyRotateFile transport can rotate files by minute, hour, day, month, year
5858
});
5959

6060
logger.info('Hello World!');
61+
62+
```
63+
64+
### ES6
65+
66+
``` js
67+
import * as winston from 'winston';
68+
import 'winston-daily-rotate-file';
69+
70+
71+
const transport = new winston.transports.DailyRotateFile({
72+
filename: 'application-%DATE%.log',
73+
datePattern: 'YYYY-MM-DD-HH',
74+
zippedArchive: true,
75+
maxSize: '20m',
76+
maxFiles: '14d'
77+
});
78+
79+
transport.on('rotate', function(oldFilename, newFilename) {
80+
// do something fun
81+
});
82+
83+
const logger = winston.createLogger({
84+
transports: [
85+
transport
86+
]
87+
});
88+
89+
logger.info('Hello World!');
90+
```
91+
92+
### Typescript
93+
94+
``` typescript
95+
96+
import * as winston from 'winston';
97+
import DailyRotateFile from 'winston-daily-rotate-file';
98+
99+
const transport: DailyRotateFile = new DailyRotateFile({
100+
filename: 'application-%DATE%.log',
101+
datePattern: 'YYYY-MM-DD-HH',
102+
zippedArchive: true,
103+
maxSize: '20m',
104+
maxFiles: '14d'
105+
});
106+
107+
transport.on('rotate', function(oldFilename, newFilename) {
108+
// do something fun
109+
});
110+
111+
const logger = winston.createLogger({
112+
transports: [
113+
transport
114+
]});
115+
116+
logger.info('Hello World!');
117+
61118
```
62119

120+
63121
This transport emits the following custom events:
64122

65123
* **new**: fired when a new log file is created. This event will pass one parameter to the callback (*newFilename*).

0 commit comments

Comments
 (0)