Skip to content

Commit

Permalink
Allow to duplicate logs to stdout channel.
Browse files Browse the repository at this point in the history
Co-authored-by: Vadim Rutkovsky <[email protected]>
  • Loading branch information
xvitaly and vrutkovs committed Aug 8, 2020
1 parent 4530b2a commit 77dcbbb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config/ecasbot.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"restlangs": [],
"hidejoins": true,
"language": "en",
"rotatelogs": false
"rotatelogs": false,
"duplicatelogs": false
}
4 changes: 3 additions & 1 deletion docs/schema-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ Available options of the `acasbot.json` configuration file:
* `restlangs` - the list of restricted languages. The bot will score users using them in their clients;
* `hidejoins` - enable or disable removing of join messages;
* `language` - the default language for the logs and the internal messages;
* `rotatelogs` - use an internal log rotate function (useful for configurations without logrotate.d; always enabled on all non-POSIX systems).
* `rotatelogs` - use an internal log rotate function (useful for configurations without logrotate.d; always enabled on all non-POSIX systems);
* `duplicatelogs` - allow to duplicate logs to stdout channel when logging to files is enabled.

# Schema changes

## From 10 to 11
The field `rotatelogs` was added. The default value is `false`.
The field `duplicatelogs` was added. The default value is `false`.

## From 9 to 10
The field `language` was added. The default value is `en`.
Expand Down
2 changes: 1 addition & 1 deletion ecasbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def __set_logger(self) -> None:
if self.__settings.rotatelogs else logging.FileHandler(self.__settings.logtofile)
f_handler.setFormatter(logging.Formatter(self.__settings.fmtlog))
self.__logger.addHandler(f_handler)
else:
if (not self.__settings.logtofile) or self.__settings.duplicate_logs:
e_handler = logging.StreamHandler(sys.stdout)
e_handler.setFormatter(logging.Formatter(self.__settings.fmterr))
self.__logger.addHandler(e_handler)
Expand Down
8 changes: 8 additions & 0 deletions ecasbot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ def hide_join_messages(self) -> bool:
"""
return self.__data['hidejoins']

@property
def duplicate_logs(self) -> bool:
"""
Duplicate logs to stdout channel when logging to files is enabled.
:return: Return True if duplicating logs to stdout is enabled.
"""
return self.__data['duplicatelogs']

def __check_watchers(self, chatid: int):
"""
Check if specified chat ID listed in watch list.
Expand Down

0 comments on commit 77dcbbb

Please sign in to comment.