Skip to content

Commit

Permalink
replace the old log module with "winston"
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyi-zhang committed Mar 27, 2017
1 parent 7ed47c7 commit 68c63c4
Show file tree
Hide file tree
Showing 71 changed files with 666 additions and 582 deletions.
45 changes: 0 additions & 45 deletions .logule.json

This file was deleted.

13 changes: 7 additions & 6 deletions brokerserver.js
@@ -1,8 +1,8 @@
'use strict';

var async = require('async');
var fs = require("fs");
var path = require("path");
var fs = require('fs');
var path = require('path');
var common = require('./lib/common');
var msRestRequest = require('./lib/common/msRestRequest');
var Broker = require('./lib/broker');
Expand All @@ -11,8 +11,9 @@ global.modules = {};

var config = common.getConfigurations();
var broker = new Broker(config);
var log = require('winston').loggers.get(common.LOG_CONSTANTS.BROKER);

msRestRequest.init(config.azure, broker.log);
msRestRequest.init(config.azure);

var addListeners = function(serviceId, serviceModule) {
broker.on('provision-' + serviceId, serviceModule.provision);
Expand All @@ -22,7 +23,7 @@ var addListeners = function(serviceId, serviceModule) {
broker.on('unbind-' + serviceId, serviceModule.unbind);
};

broker.log.info('Starting to collect the service offering and plans of each service module...');
log.info('Starting to collect the service offering and plans of each service module...');

var params = {};
params.azure = config.azure;
Expand All @@ -41,11 +42,11 @@ fs.readdir(servicesPath, function(err, files) {
return fs.statSync(file).isDirectory();
}).forEach(function(file) {
var serviceModule = require('./' + file);
serviceModule.catalog(broker.log, params, function(err, service) {
serviceModule.catalog(params, function(err, service) {
if (err) {
throw err;
} else {
broker.log.info('Adding listeners for the service %s...', service.name);
log.info('Adding listeners for the service %s...', service.name);
addListeners(service.id, serviceModule);
services.push(service);
global.modules[service.id] = serviceModule;
Expand Down
20 changes: 10 additions & 10 deletions docs/how-admin-deploy-the-broker.md
Expand Up @@ -230,22 +230,22 @@ cf delete-service-broker demo-service-broker -f

## Debug logging

By default, the debug logging is disabled. If you want to enable the debug logging, please remove `debug` from the `suppress` list in `.logule.json`. Here is the [reference](https://github.com/clux/logule#configuration).
By default, the debug logging is disabled. If you want to enable the debug logging, please change `"level": "info"` to `"level": "debug"` in `winston.json`. Here is the [reference](https://github.com/winstonjs/winston/blob/fcf04e1dece55ec1dd100e4a8a2cdcda91146e74/docs/transports.md#console-transport).

```
"stdout" : {
"pad" : 0,
"delimiter" : " - ",
"nesting" : 3,
"mutable" : true,
"timestamp" : "toLocaleTimeString",
"suppress" : ["debug"]
},
{
"console": {
"level": "info",
"debugStdout": true,
"colorize": true,
"prettyPrint": true
}
}
```

You can enable the debug logging when you deploy the service broker at the first time. Then you will get the debug messages. On the other hand, you can also enable it after the service broker is registered, but you need to update the service broker. The steps:

1. Enable debug logging in `.logule.json`.
1. Enable debug logging in `winston.json`.

2. Re-push the broker to Cloud Foundry.

Expand Down
24 changes: 12 additions & 12 deletions docs/service-module-design.md
Expand Up @@ -2,12 +2,12 @@

You need to implement the following functions in the service module.

* Handlers.catalog = function(log, params, next)
* Handlers.provision = function(log, params, next)
* Handlers.poll = function(log, params, next)
* Handlers.deprovision = function(log, params, next)
* Handlers.bind = function(log, params, next)
* Handlers.unbind = function(log, params, next)
* Handlers.catalog = function(params, next)
* Handlers.provision = function(params, next)
* Handlers.poll = function(params, next)
* Handlers.deprovision = function(params, next)
* Handlers.bind = function(params, next)
* Handlers.unbind = function(params, next)

About the parameters

Expand Down Expand Up @@ -35,7 +35,7 @@ About the parameters

### catalog function

Handlers.catalog = function(log, params, next)
Handlers.catalog = function(params, next)

* params

Expand Down Expand Up @@ -88,7 +88,7 @@ http://docs.cloudfoundry.org/services/api.html#catalog-mgmt

### Provision function

Handlers.provision = function(log, params, next)
Handlers.provision = function(params, next)

It should be an asynchronous operation.

Expand Down Expand Up @@ -169,7 +169,7 @@ It should be an asynchronous operation.

### Poll function

Handlers.poll = function(log, params, next)
Handlers.poll = function(params, next)

* params

Expand Down Expand Up @@ -232,7 +232,7 @@ Handlers.poll = function(log, params, next)

### Deprovision function

Handlers.deprovision = function(log, params, next)
Handlers.deprovision = function(params, next)

It should be an asynchronous operation.

Expand Down Expand Up @@ -289,7 +289,7 @@ It should be an asynchronous operation.

### Bind function

Handlers.bind = function(log, params, next)
Handlers.bind = function(params, next)

* params

Expand Down Expand Up @@ -352,7 +352,7 @@ Handlers.bind = function(log, params, next)

### Unbind function

Handlers.unbind = function(log, params, next)
Handlers.unbind = function(params, next)

When the unbinding function of the service module is called, the broker will delete the binding specific information (everything associated with the bindingId.).

Expand Down
2 changes: 0 additions & 2 deletions lib/broker/db/index.js
@@ -1,13 +1,11 @@
'use strict';
var Logule = require('logule');
var Sqlserver = require('./sqlserver');

var Database = function(opts) {
var db = new Sqlserver(opts);

db.instanceTableName = 'instances';
db.bindingTableName = 'bindings';
db.log = Logule.init(module, db.name);
return db;
};

Expand Down

0 comments on commit 68c63c4

Please sign in to comment.