Skip to content

Commit

Permalink
Remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
s0undt3ch committed Feb 27, 2024
1 parent 0cb7b6f commit 7850ef0
Show file tree
Hide file tree
Showing 15 changed files with 1 addition and 978 deletions.
1 change: 0 additions & 1 deletion doc/ref/modules/all/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ execution modules
cabal
capirca_acl
cassandra_cql
cassandra_mod
celery
ceph
chassis
Expand Down
5 changes: 0 additions & 5 deletions doc/ref/modules/all/salt.modules.cassandra_mod.rst

This file was deleted.

2 changes: 0 additions & 2 deletions doc/ref/returners/all/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ returner modules
appoptics_return
carbon_return
cassandra_cql_return
cassandra_return
couchbase_return
couchdb_return
django_return
elasticsearch_return
etcd_return
highstate_return
Expand Down
5 changes: 0 additions & 5 deletions doc/ref/returners/all/salt.returners.cassandra_return.rst

This file was deleted.

5 changes: 0 additions & 5 deletions doc/ref/returners/all/salt.returners.django_return.rst

This file was deleted.

2 changes: 1 addition & 1 deletion doc/topics/development/modules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Execution ``salt.modules`` (:ref:`index <all-salt.modules>`) ``
Executor ``salt.executors`` (:ref:`index <all-salt.executors>`) ``executors`` ``executor_dirs``
File Server ``salt.fileserver`` (:ref:`index <file-server>`) ``fileserver`` ``fileserver_dirs``
Grain ``salt.grains`` (:ref:`index <all-salt.grains>`) ``grains`` ``grains_dirs``
Log Handler ``salt.log.handlers`` (:ref:`index <external-logging-handlers>`) ``log_handlers`` ``log_handlers_dirs``
Log Handler ``salt.log_handlers`` (:ref:`index <external-logging-handlers>`) ``log_handlers`` ``log_handlers_dirs``
Matcher ``salt.matchers`` ``matchers`` ``matchers_dirs``
Metaproxy ``salt.metaproxy`` ``metaproxy`` [#no-fs]_ ``metaproxy_dirs``
Net API ``salt.netapi`` (:ref:`index <all-netapi-modules>`) ``netapi`` [#no-fs]_ ``netapi_dirs``
Expand Down
142 changes: 0 additions & 142 deletions salt/_logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,16 @@
Salt's logging handlers
"""

import copy
import logging
import logging.handlers
import queue as _queue
import sys
from collections import deque

from salt._logging.mixins import ExcInfoOnLogLevelFormatMixin
from salt.utils.versions import warn_until_date

log = logging.getLogger(__name__)


class TemporaryLoggingHandler(logging.NullHandler):
"""
This logging handler will store all the log records up to its maximum
queue size at which stage the first messages stored will be dropped.
Should only be used as a temporary logging handler, while the logging
system is not fully configured.
Once configured, pass any logging handlers that should have received the
initial log messages to the function
:func:`TemporaryLoggingHandler.sync_with_handlers` and all stored log
records will be dispatched to the provided handlers.
.. versionadded:: 0.17.0
"""

def __init__(self, level=logging.NOTSET, max_queue_size=10000):
warn_until_date(
"20240101",
"Please stop using '{name}.TemporaryLoggingHandler'. "
"'{name}.TemporaryLoggingHandler' will go away after "
"{{date}}.".format(name=__name__),
)
super().__init__(level=level)
self.__messages = deque(maxlen=max_queue_size)

def handle(self, record):
self.acquire()
self.__messages.append(record)
self.release()

def sync_with_handlers(self, handlers=()):
"""
Sync the stored log records to the provided log handlers.
"""
if not handlers:
return

while self.__messages:
record = self.__messages.popleft()
for handler in handlers:
if handler.level > record.levelno:
# If the handler's level is higher than the log record one,
# it should not handle the log record
continue
handler.handle(record)


class StreamHandler(ExcInfoOnLogLevelFormatMixin, logging.StreamHandler):
"""
Stream handler which properly handles exc_info on a per handler basis
Expand Down Expand Up @@ -214,94 +163,3 @@ class WatchedFileHandler(
"""
Watched file handler which properly handles exc_info on a per handler basis
"""


if sys.version_info < (3, 7):
# On python versions lower than 3.7, we sill subclass and overwrite prepare to include the fix for:
# https://bugs.python.org/issue35726
class QueueHandler(
ExcInfoOnLogLevelFormatMixin, logging.handlers.QueueHandler
): # pylint: disable=no-member,inconsistent-mro
def __init__(self, queue): # pylint: disable=useless-super-delegation
super().__init__(queue)
warn_until_date(
"20240101",
"Please stop using '{name}.QueueHandler' and instead "
"use 'logging.handlers.QueueHandler'. "
"'{name}.QueueHandler' will go away after "
"{{date}}.".format(name=__name__),
)

def enqueue(self, record):
"""
Enqueue a record.
The base implementation uses put_nowait. You may want to override
this method if you want to use blocking, timeouts or custom queue
implementations.
"""
try:
self.queue.put_nowait(record)
except _queue.Full:
sys.stderr.write(
"[WARNING ] Message queue is full, "
'unable to write "{}" to log.\n'.format(record)
)

def prepare(self, record):
"""
Prepares a record for queuing. The object returned by this method is
enqueued.
The base implementation formats the record to merge the message
and arguments, and removes unpickleable items from the record
in-place.
You might want to override this method if you want to convert
the record to a dict or JSON string, or send a modified copy
of the record while leaving the original intact.
"""
# The format operation gets traceback text into record.exc_text
# (if there's exception data), and also returns the formatted
# message. We can then use this to replace the original
# msg + args, as these might be unpickleable. We also zap the
# exc_info and exc_text attributes, as they are no longer
# needed and, if not None, will typically not be pickleable.
msg = self.format(record)
# bpo-35726: make copy of record to avoid affecting other handlers in the chain.
record = copy.copy(record)
record.message = msg
record.msg = msg
record.args = None
record.exc_info = None
record.exc_text = None
return record

else:

class QueueHandler(
ExcInfoOnLogLevelFormatMixin, logging.handlers.QueueHandler
): # pylint: disable=no-member,inconsistent-mro
def __init__(self, queue): # pylint: disable=useless-super-delegation
super().__init__(queue)
warn_until_date(
"20240101",
"Please stop using '{name}.QueueHandler' and instead "
"use 'logging.handlers.QueueHandler'. "
"'{name}.QueueHandler' will go away after "
"{{date}}.".format(name=__name__),
)

def enqueue(self, record):
"""
Enqueue a record.
The base implementation uses put_nowait. You may want to override
this method if you want to use blocking, timeouts or custom queue
implementations.
"""
try:
self.queue.put_nowait(record)
except _queue.Full:
sys.stderr.write(
"[WARNING ] Message queue is full, "
'unable to write "{}" to log.\n'.format(record)
)
33 changes: 0 additions & 33 deletions salt/log/__init__.py

This file was deleted.

20 changes: 0 additions & 20 deletions salt/log/handlers/__init__.py

This file was deleted.

17 changes: 0 additions & 17 deletions salt/log/mixins.py

This file was deleted.

Loading

0 comments on commit 7850ef0

Please sign in to comment.