forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHORE] Remove calls to jsonbin (hedyorg#4200)
In the beginning of Hedy, we logged to jsonbin for simplicity, but we have since professionalized and now also log to s3. We can stop to also log to jsonbin (we did both because I was scared of losing logs and then we never removed jsonbin)
- Loading branch information
Showing
4 changed files
with
42 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import logging | ||
|
||
from . import aws_helpers, log_queue | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class NullLogger: | ||
"""A logger that doesn't actually do anything.""" | ||
|
||
def log(self, obj): | ||
pass | ||
|
||
|
||
class S3ParseLogger: | ||
"""A logger that logs to S3. | ||
""" | ||
|
||
@staticmethod | ||
def from_env_vars(): | ||
transmitter = aws_helpers.s3_parselog_transmitter_from_env() | ||
if not transmitter: | ||
return NullLogger() | ||
|
||
S3_LOG_QUEUE.set_transmitter(transmitter) | ||
return S3ParseLogger() | ||
|
||
def log(self, obj): | ||
S3_LOG_QUEUE.add(obj) | ||
|
||
|
||
S3_LOG_QUEUE = log_queue.LogQueue("parse", batch_window_s=300) | ||
S3_LOG_QUEUE.try_load_emergency_saves() | ||
|
||
|
||
def emergency_shutdown(): | ||
"""The process is being killed. Do whatever needs to be done to save the logs.""" | ||
S3_LOG_QUEUE.emergency_save_to_disk() |