mirror of
https://github.com/appium/appium.git
synced 2026-05-23 04:18:53 -05:00
No more plain console.log across node js code.
This commit is contained in:
+3
-2
@@ -2,6 +2,7 @@
|
||||
// https://github.com/hugs/appium/blob/master/appium/appium.py
|
||||
"use strict";
|
||||
var routing = require('./routing')
|
||||
, logger = require('../logger').get('appium')
|
||||
, UUID = require('uuid-js')
|
||||
, ios = require('./ios');
|
||||
|
||||
@@ -42,7 +43,7 @@ Appium.prototype.invoke = function() {
|
||||
|
||||
if (this.sessionId === null) {
|
||||
this.sessionId = UUID.create().hex;
|
||||
console.log('Creating new appium session ' + this.sessionId);
|
||||
logger.info('Creating new appium session ' + this.sessionId);
|
||||
|
||||
// in future all the blackberries go here.
|
||||
this.active = 'iOS';
|
||||
@@ -70,7 +71,7 @@ Appium.prototype.stop = function(cb) {
|
||||
|
||||
var me = this;
|
||||
|
||||
console.log('Shutting down appium session...');
|
||||
logger.info('Shutting down appium session...');
|
||||
this.device.stop(function() {
|
||||
me.sessionId = null;
|
||||
me.devices = {};
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@
|
||||
var path = require('path')
|
||||
, rimraf = require('rimraf')
|
||||
, fs = require('fs')
|
||||
, logger = require('../logger').get('appium')
|
||||
, sock = '/tmp/instruments_sock'
|
||||
, instruments = require('../instruments/instruments');
|
||||
|
||||
@@ -32,7 +33,7 @@ IOS.prototype.start = function(cb) {
|
||||
var me = this;
|
||||
|
||||
var onLaunch = function() {
|
||||
console.log('Instruments launched. Starting poll loop for new commands.');
|
||||
logger.info('Instruments launched. Starting poll loop for new commands.');
|
||||
me.instruments.setDebug(true);
|
||||
cb(null, me);
|
||||
};
|
||||
@@ -78,7 +79,7 @@ IOS.prototype.stop = function(cb) {
|
||||
IOS.prototype.proxy = function(command, cb) {
|
||||
// was thinking we should use a queue for commands instead of writing to a file
|
||||
this.push([command, cb]);
|
||||
console.log('Pushed command to appium work queue: ' + command);
|
||||
logger.info('Pushed command to appium work queue: ' + command);
|
||||
};
|
||||
|
||||
IOS.prototype.push = function(elem) {
|
||||
|
||||
+11
-10
@@ -3,6 +3,7 @@
|
||||
|
||||
var spawn = require('child_process').spawn
|
||||
, colors = require('colors')
|
||||
, logger = require('../logger').get('instruments')
|
||||
, fs = require('fs')
|
||||
, _ = require('underscore')
|
||||
, net = require('net');
|
||||
@@ -62,10 +63,10 @@ Instruments.prototype.startSocketServer = function(sock) {
|
||||
// when data comes in, route it according to the "event" property
|
||||
data = JSON.parse(data);
|
||||
if (!_.has(data, 'event')) {
|
||||
console.log("Error: socket data came in witout event, it was:");
|
||||
console.log(JSON.stringify(data));
|
||||
logger.error("Socket data came in witout event, it was:");
|
||||
logger.error(JSON.stringify(data));
|
||||
} else if (!_.has(this.eventRouter, data.event)) {
|
||||
console.log("Error: socket is asking for event '" + data.event +
|
||||
logger.error("Socket is asking for event '" + data.event +
|
||||
"' which doesn't exist");
|
||||
} else {
|
||||
this.debug("Socket data being routed for '" + data.event + "' event");
|
||||
@@ -116,9 +117,9 @@ Instruments.prototype.spawnInstruments = function() {
|
||||
Instruments.prototype.commandHandler = function(data, c) {
|
||||
var hasResult = typeof data.result !== "undefined";
|
||||
if (hasResult && !this.curCommand) {
|
||||
console.log("Got a result when we weren't expecting one! Ignoring it");
|
||||
logger.info("Got a result when we weren't expecting one! Ignoring it");
|
||||
} else if (!hasResult && this.curCommand) {
|
||||
console.log("Instruments didn't send a result even though we were expecting one");
|
||||
logger.info("Instruments didn't send a result even though we were expecting one");
|
||||
hasResult = true;
|
||||
data.result = false;
|
||||
}
|
||||
@@ -191,7 +192,7 @@ Instruments.prototype.outputStreamHandler = function(output) {
|
||||
};
|
||||
|
||||
Instruments.prototype.errorStreamHandler = function(output) {
|
||||
console.log(("[INST STDERR] " + output).yellow);
|
||||
logger.error(("[INST STDERR] " + output).yellow);
|
||||
};
|
||||
|
||||
Instruments.prototype.lookForShutdownInfo = function(output) {
|
||||
@@ -213,16 +214,16 @@ Instruments.prototype.defaultResultHandler = function(output) {
|
||||
// if we have multiple log lines, indent non-first ones
|
||||
if (output !== "") {
|
||||
output = output.replace(/\n/m, "\n ");
|
||||
console.log(("[INST] " + output).blue);
|
||||
logger.info(("[INST] " + output).blue);
|
||||
}
|
||||
};
|
||||
|
||||
Instruments.prototype.defaultReadyHandler = function() {
|
||||
console.log("Instruments is ready and waiting!");
|
||||
logger.info("Instruments is ready and waiting!");
|
||||
};
|
||||
|
||||
Instruments.prototype.defaultExitHandler = function(code, traceDir) {
|
||||
console.log("Instruments exited with code " + code + " and trace dir " + traceDir);
|
||||
logger.info("Instruments exited with code " + code + " and trace dir " + traceDir);
|
||||
};
|
||||
|
||||
|
||||
@@ -236,7 +237,7 @@ Instruments.prototype.setDebug = function(debug) {
|
||||
};
|
||||
|
||||
Instruments.prototype.debug = function(msg) {
|
||||
console.log(("[INSTSERVER] " + msg).grey);
|
||||
logger.info(("[INSTSERVER] " + msg).grey);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ var http = require('http')
|
||||
, rest = express()
|
||||
, path = require('path')
|
||||
, server = http.createServer(rest)
|
||||
, logger = require('./logger').get('appium')
|
||||
, appium = require('./app/appium')
|
||||
, parser = require('./app/parser');
|
||||
|
||||
@@ -38,7 +39,7 @@ var main = function(args, readyCb, doneCb) {
|
||||
// Start the web server that receives all the commands
|
||||
server.listen(args.port, args.address, function() {
|
||||
var logMessage = "Appium REST http interface listener started on "+args.address+":"+args.port;
|
||||
console.log(logMessage.cyan);
|
||||
logger.info(logMessage.cyan);
|
||||
if (readyCb) {
|
||||
readyCb();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user