Commit 45d90a57 authored by tobinski's avatar tobinski
Browse files

Remove all console log statements

parent 1db3ef32
Pipeline #3573 canceled with stage
......@@ -24,9 +24,11 @@ kafkaLog.addStream({
/**
* Init the core
* todo: perhaps into module with exports. Then we could interact more freely with it
* @type {Core}
*/
export const core = Core.init('Api', './config.json');
export const logger = core.getLogger();
// Create Express server
const app = express();
......@@ -131,14 +133,14 @@ kafka.init().then(async () => {
*/
app.use((err, req, res, next) => {
if (err.isServer) {
console.error(err.output);
core.getLogger().error(err.output);
}
return res.status(err.output.statusCode).json(err.output.payload);
});
core.getLogger().info("We are ready to interact with kafka")
}).catch((error) => {
core.getLogger().error('error while connecting to kafka');
core.getLogger().error('Problem to connect to kafka');
throw error;
});
......
......@@ -207,7 +207,6 @@ export class ApiController {
* On data, write stuff to kafka
*/
try {
console.log(message);
req.kafkaProducer.produce('request-geoconcordance', -1, message, id);
core.getReporter().setDataOut(1);
} catch (error) {
......
import errorHandler = require('errorhandler');
import app from './app';
import app, {logger} from './app';
/**
* Error Handler. Provides full stack - remove for production
......@@ -11,12 +11,8 @@ app.use(errorHandler());
* Start Express server.
*/
const server = app.listen(app.get('port'), () => {
console.log(
' App is running at http://localhost:%d in %s mode',
app.get('port'),
app.get('env')
);
console.log(' Press CTRL-C to stop\n');
logger.info('App is running at http://localhost:%d in %s mode', app.get('port'), app.get('env'));
logger.info('Press CTRL-C to stop');
});
export default server;
\ No newline at end of file
import {logger} from '../app';
const EventEmitter = require('events');
class KafkaEventEmitter extends EventEmitter {}
// event emitter for kafka events
......@@ -5,8 +6,8 @@ const kafkaEventEmitter = new KafkaEventEmitter();
// allow more than 10 parallel event listeners
kafkaEventEmitter.setMaxListeners(100);
kafkaEventEmitter.on('error', (err) => {
console.error('There was an error in the kafkaEventEmitter');
console.error(err);
logger.error('There was an error in the kafkaEventEmitter');
logger.error(err);
process.exit(1);
});
export default kafkaEventEmitter;
import {logger} from '../app';
/**
* Small class to stop the time and di a reporting
*/
......@@ -16,9 +18,9 @@ class Timer {
report(lab?: string) {
if(typeof this.labs[lab] === 'undefined') return null;
console.log("start :" + this.labs[lab].start);
logger.info("Start timer lab:" + this.labs[lab].start);
for(let steps of this.labs[lab].lab) {
console.log("lab :" + ( steps - this.labs[lab].start) + 'ms');
logger.info("Lab time:" + ( steps - this.labs[lab].start) + 'ms');
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment