You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Readme.md
+14-15
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
1
# micrologger
2
2
3
-
Meaningful application and request logs to be used with koa microservices
3
+
Simple but meaningful application and request logs to be used with koa microservices
4
4
5
5
Support for rotating files and/or sending to a logging collector fluentd (more to come)
6
6
7
-
Add to the top of your koa application and pass in koa app:
7
+
Add to the top of your koa application and pass in koa app to get started:
8
8
9
9
```js
10
10
constapp=require('koa')();
11
11
constlogger=require('micrologger');
12
-
logger(app);
12
+
app.use(logger());
13
13
```
14
14
This will give you all application and request logs:
15
15
16
16
Make sure to pass NODE_ENV=development for local development
17
17
18
-
Rotating log files will be saved to 'logs/out.log' in the root of your app. Rotating files can be turned off by passing in logToFile:false
18
+
Rotating log files will be saved to 'logs/out.log' in the root of your app. Pass logToFile:true in the options and pass in NODE_ENV=developemnt to use rotating files
19
19
20
20
That is all you need for micrologger to start collecting and sending logs.
21
21
@@ -109,12 +109,12 @@ You can add fluentd as a collector
109
109
add the fluent block below and all the logs will be sent to fluentd
110
110
111
111
```js
112
-
logger(app, {
112
+
app.use(logger({
113
113
fluent: {
114
114
host:'127.0.0.1',
115
115
port:'24224'
116
116
}
117
-
});
117
+
}))
118
118
```
119
119
120
120
```sh
@@ -136,7 +136,7 @@ Example of application error in /logs/out.log
136
136
## Log info/error
137
137
```js
138
138
logger.info('Info Message');
139
-
logger.info('Some error message');
139
+
logger.error('Some error message');
140
140
```
141
141
The info and error message will be logged with the following structure:
142
142
@@ -165,18 +165,17 @@ The info and error message will be logged with the following structure:
165
165
## All options
166
166
167
167
```js
168
-
logger(app, {
168
+
app.use(logger({
169
169
logsToFile:false,
170
-
requestLogs:false,
171
-
appLogs:false,
170
+
appLogs:true,
172
171
backgroundColor:'dark',
173
172
fluent: {
174
173
host:'127.0.0.1',
175
174
port:'24224'
176
175
}
177
-
})
176
+
}))
178
177
```
179
-
* logToFile: (default is true)
180
-
*requestLogs: (default is true)
181
-
*appLogs: (default is true)
182
-
*backgroundColor: this is the background color of your terminal. options are dark/light (default is dark)
178
+
* logToFile: (optional, default is false)
179
+
*appLogs: (optional, default is true) if set to false application errors will not be logged. This does not include request errors
180
+
*backgroundColor: (optional) this is the background color of your terminal. options are dark/light (default is dark)
0 commit comments