Skip to content

Commit

Permalink
Enable Logging (#24)
Browse files Browse the repository at this point in the history
* Add poetry skeleton

* Add precommit file config

* Add discord as dependency

* Add tox configuration files and pass precommit

* Change the author of the project

* GitHub actions (#2)

Create build using github action

* Bot skeleton (#4)

* Add dummy commit to test GH

* Change name of precommit file

* Add dummy skeleton to test build

* Add Dockerfile

* Add production github action

* Add author to dockerfile

* Fix docker file not getting image in FROM (#5)

* Docker file fix v2 (#6)

Fix problem with name in the registry

* Add PR template file (#7)

* Add PR template file

* Change semantic of type of change

* Add documentation as option

* Rename az registries information (#8)

* Rename az registries information

* Rename pull request template

* Rename PR template

* React with reaction (#9)

* Test PR template

* Update version of discordpy dependency

* Initial architecture of bot

* Change tox and preconfig files

* Test build

* Add cog automatical registration

* Add discord token as secure env var

* Test no cog registration (#10)

* Fix problem with relative path (#11)

* Fix linter config (#14)

* Unit test and documentation for blueprint bot (#12)

* Add unit test for intent registration

* Add unit testing for startup

* Add test for startup cogs

* Create unit testing for formatters

* Update constants.py

Co-Authored-By: Manuel CH <[email protected]>

* Test precommit

* Create unit testing for formatters

* Add Readme

* Fix typo in readme

* Ignore rule to avoid unneccesary comments

* Delete unnecesary comments

* Move fixture to conftest

Co-authored-by: Manuel CH <[email protected]>

* Add initial base for timeline (#15)

* Add initial base for timeline

* Add unit testing for hiring formatter

* Add cron testing

* Add unit testing for cog

* Change formatter access

* Migrate cron to enum

* Add annoucement channel as secret for deployment

* Add start stop cron schedule

* Missing root folder name was failing deploy to Azure (#16)

* Debug state

* Change to PR

* Add analytics to container

* Add cogs again

* Remove path

* Enable cogs again

* Test

* Rename Docker root file

* Add module parameter to Dockerfile

* Add complete path

* Uncomment cogs

* Comment hiring

* Add logg

* Test

* Add complete path to cogs

* Put release again on merge

* Fix tox passing failing tests

* Fix tox

* Change tox

* FIx tox

* Tox should trigger

* Skip update dependency

* Delete install

* Add pytest

* Return pytest

* Test should fail

* Change test to build

* Uncomment test cog

* Revert push to prod to merge

* Prepare deploy with different envs

* Test dev deploy

* Test secrets

* Add env vars for deploy

* Fix if

* Split dev and prod

* Comment test phase

* Disable beta command (#18)

* Comment beta command

* Modify tests

* Add logging decorator (#20)

* Add logging decorator

* Test log in az dev

* Test in developent environment

* Change policy (#23)

* Change policy

* Disable push in pull request

* Fix lintern problems

Co-authored-by: Manuel CH <[email protected]>
  • Loading branch information
GoberInfinity and akotadi authored Jan 10, 2023
1 parent 1218f3c commit bd691d6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/push_to_dev.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Push Bot To Dev

on:
pull_request:
branches: [develop]
push:
branches: [develop]

Expand Down
3 changes: 3 additions & 0 deletions otter_welcome_buddy/cogs/hiring_timelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from otter_welcome_buddy.common.constants import CronExpressions
from otter_welcome_buddy.common.utils.dates import DateUtils
from otter_welcome_buddy.formatters import timeline
from otter_welcome_buddy.log import wrapper


class Timelines(commands.Cog):
Expand All @@ -26,6 +27,7 @@ async def stop(self, _):
"""Command to interact with the bot and start cron"""
self.scheduler.stop()

@wrapper.log_function()
def __configure_scheduler(self):
"""Configure and start scheduler"""
self.scheduler.add_job(
Expand All @@ -42,6 +44,7 @@ def _get_hiring_events(self):
DateUtils.get_current_month()
)

@wrapper.log_function()
async def send_message_on_channel(self):
"""Sends message to announcement channel at the start of month"""
channel_id = int(os.environ["ANNOUNCEMENT_CHANNEL_ID"])
Expand Down
Empty file.
20 changes: 20 additions & 0 deletions otter_welcome_buddy/log/wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import logging
from functools import wraps


def log_function(level=logging.INFO, message=None):
"""Decorator to log that the function is being called"""

def decorate(func):
logmsg = message if message else func.__module__ + "." + func.__name__

@wraps(func)
def wrapper(*args, **kwargs):
# We need to create proper class to init Logger instead of setting log level
logging.getLogger().setLevel(logging.INFO)
logging.log(level, logmsg)
return func(*args, **kwargs)

return wrapper

return decorate

0 comments on commit bd691d6

Please sign in to comment.