Skip to content

Commit

Permalink
rollbar stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pipermerriam committed Sep 30, 2016
1 parent f35028c commit 4060521
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build/
dist/
chains/
**/_build
.env
12 changes: 12 additions & 0 deletions alarm_client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pkg_resources


__version__ = pkg_resources.get_distribution("ethereum-alarm-clock-client").version


try:
# load environment variables
import dotenv
dotenv.load_dotenv('.env')
except ImportError:
pass
34 changes: 32 additions & 2 deletions alarm_client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@
}


def is_rollbar_available():
try:
import rollbar # noqa
except ImportError:
return False
else:
return (
'ROLLBAR_SECRET' in os.environ and
'ROLLBAR_ENVIRONMENT' in os.environ
)


class Config(object):
web3 = None

Expand Down Expand Up @@ -90,8 +102,10 @@ def __init__(self,
def get_logger(self, name):
logger = logging.getLogger(name)
logger.setLevel(self.log_level)

has_stream_handler = any(
isinstance(handler, logging.StreamHandler) for handler in logger.handlers
isinstance(handler, logging.StreamHandler)
for handler in logger.handlers
)
if not has_stream_handler:
stream_handler = logging.StreamHandler()
Expand All @@ -112,8 +126,24 @@ def get_logger(self, name):
backupCount=20,
maxBytes=10000000)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(logging.Formatter('%(levelname)s: %(asctime)s %(message)s'))
file_handler.setFormatter(logging.Formatter(
'%(levelname)s: %(asctime)s %(message)s'
))
logger.addHandler(file_handler)

if is_rollbar_available():
from rollbar.logger import RollbarHandler
has_rollbar_handler = any(
isinstance(handler, RollbarHandler)
for handler in logger.handlers
)
if not has_rollbar_handler:
rb_handler = RollbarHandler(
os.environ['ROLLBAR_SECRET'],
os.environ['ROLLBAR_ENVIRONMENT'],
)
rb_handler.setLevel(self.log_level)
logger.addHandler(rb_handler)
return logger

@cached_property
Expand Down
8 changes: 7 additions & 1 deletion docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ Setting up an
.. _pyethereum documentation: https://github.com/ethereum/pyethereum/wiki/Developer-Notes


Rollbar Integration
-------------------

TODO


Running a server
----------------

Expand All @@ -90,7 +96,7 @@ steps should get an EC2 instance provisioned with the scheduler running.

* ``sudo apt-get update --fix-missing``
* ``sudo apt-get install -y supervisor``
* ``sudo apt-get install -y python-dev python build-essential libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev python-virtualenv``
* ``sudo apt-get install -y python3-dev python build-essential libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev python-virtualenv``

3. Mount the extra volume
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ eth-testrpc>=0.8.4
ethereum-tester-client>=1.2.2
click>=6.6
pylru>=1.0.9
python-dotenv>=0.6.0
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"populus>=1.2.0",
"web3>=3.0.0",
"pylru>=1.0.9",
"python-dotenv>=0.6.0",
],
license="MIT",
zip_safe=False,
Expand Down

0 comments on commit 4060521

Please sign in to comment.