Skip to content

Commit

Permalink
Merge pull request #43 from browserium/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Soumyajit Basu (C0r3f!nd3r) authored Sep 8, 2018
2 parents 2103a3d + 15bf667 commit a3d75c2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ browserium.egg-info/
dist/
build/
TestFunction/geckodriver.log
nohup.out
TestFunction/logstash.db
9 changes: 9 additions & 0 deletions TestFunction/test_chrome.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from browserium.generic_functions.chrome_object import ChromeDriverObject
from browserium.generic_functions.browser_controller import Browser_controller
from browserium.generic_functions.logger import Logstash
from time import sleep

class Test_1():
def test_chromedriver_type1(self):
chromedriver = ChromeDriverObject()
controller = Browser_controller()
driver = chromedriver.set_chromedriver_object()
log = Logstash()
controller.get_url(driver, "https://www.google.co.in")
controller.implicit_wait_time(driver, 4)
controller.set_window_size(driver, "1440", "900")
Expand All @@ -22,12 +24,16 @@ def test_chromedriver_type1(self):
print site_cookies
current_url = controller.get_current_url(driver)
print current_url
log.logstash_type("INFO","Test")
log.logstash_type("ERROR","Test")
log.logstash_type("WARNING","Test")
driver.quit()

def test_chromedriver_type2(self):
chromedriver = ChromeDriverObject()
controller = Browser_controller()
driver = chromedriver.set_chromedriver_object("--headless")
log = Logstash()
controller.get_url(driver, "https://www.google.co.in")
controller.implicit_wait_time(driver, 4)
controller.set_window_size(driver, "1440", "900")
Expand All @@ -43,6 +49,9 @@ def test_chromedriver_type2(self):
print site_cookies
current_url = controller.get_current_url(driver)
print current_url
log.logstash_type("INFO","Test")
log.logstash_type("ERROR","Test")
log.logstash_type("WARNING","Test")
driver.quit()

t = Test_1()
Expand Down
24 changes: 5 additions & 19 deletions browserium/generic_functions/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
import logstash
import sys
import platform
from logstash_async.handler import AsynchronousLogstashHandler

class Logstash():
def logstash_type(self, log_type, log_message):
host = 'localhost'
port = 5959

test_logger = logging.getLogger('python-logstash-logger')

test_logger.setLevel(logging.INFO)
test_logger.addHandler(logstash.LogstashHandler(host, port, version=1))

test_logger.addHandler(AsynchronousLogstashHandler(host, port, database_path='logstash.db'))

if log_type == "ERROR":
test_logger.error(log_message)
Expand All @@ -19,21 +22,4 @@ def logstash_type(self, log_type, log_message):
test_logger.info(log_message)

if log_type == "WARNING":
test_logger.warning(log_message)

if log_type == "DEBUG":
test_logger.debug(log_message)

if log_type == "EXCEPTION":
test_logger.exception(log_message)

# add extra field to logstash message
extra = {
'Architecture': 'arch_type: ' + repr(platform.machine()),
'PlatformVersion': 'platform_version: '+ repr(platform.version()),
'SystemType': 'sys_type: '+ repr(platform.platform()),
'OperatingSystem': 'os_type: '+ repr(platform.system()),
'PlatformProcessor': 'platform_processor: '+ repr(platform.processor()),
'Python_Version': 'python version: ' + repr(sys.version_info)
}
test_logger.info('logstash-system-info: INFORMATION', extra=extra)
test_logger.warning(log_message)
2 changes: 1 addition & 1 deletion browserium/logstashRunner/logstash_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_path(path_param):

@staticmethod
def install_logstashAsync():
call(["pip", "install", "python-logstash"])
call(["pip", "install", "python-logstash-async"])

@staticmethod
def run_logstash_background():
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
],
package_data= {
'browserium.configurations': ['*.ini'],
'browserium.logstashRunner': ['*.conf'],
'browserium.utility':['*.sh']
'browserium.logstashRunner': ['*.conf']
},
include_package_data=True,
zip_safe = False,
Expand All @@ -42,7 +41,6 @@
'browserium = browserium.utility.main:main'
]
},
scripts = ['browserium/logstashRunner/logstash_runner.py'],
url = "https://github.com/browserium/Browserium",
download_url = "https://github.com/browserium/Browserium/archive/1.1.0.tar.gz"
)

0 comments on commit a3d75c2

Please sign in to comment.