Saravanan666/pypi-org huggingface dataset:
Package: logging-formatter-anticrlf
logging Formatter to sanitize CRLF errors (CWE-93, some forms of CWE-117)This class is a drop-in replacement forlogging.Formatter, and has the
exact same construction arguments. However, as a final step of formatting a
log line, it escapes carriage returns (\r) and linefeeds (\n).By default, these are replaced with their escaped equivalents (seeExamples),
but thereplacementsdictionary can be modified to change this behavior.This sanitization should solve CWE-93 errors and CRLF-based versions of
CWE-117. Some CWE-117 errors are concerns about e.g. XSS flaws in logs that
are likely to be viewed in a browser; this formatter can’t handle every
form of CWE-117.Installationpip install logging-formatter-anticrlfExamplesimport sys
import logging
import anticrlf

handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(anticrlf.LogFormatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))

logger = logging.getLogger(__name__)
logger.addHandler(handler)
logger.setLevel(logging.INFO)

logger.info("Example text with a newline\nhere")This results in:2017-02-03 08:43:52,557 - __main__ - INFO - Example text with a newline\nhereWhereas with the defaultFormatter, it would be:2017-02-03 08:43:52,557 - __main__ - INFO - Example text with a newline
hereIf you wanted newlines to be replaced with \x0A instead, you could:formatter = anticrlf.LogFormatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
formatter.replacements["\n"] = "\\x0A"  # Note the double backslash for literal!
handler.setFormatter(formatter)Changing ReplacementsThereplacementsfield of the formatter is aSubstitutionMapobject that behaves
like adictwith a few exceptions designed to help developers avoid making insecure mistakes.Specifically:an “empty”SubstitutionMapobject will contain the default mappings for CR and LF charscallingdelon either the CR or LF key willreset the valuerather thandeletethe keyany attempt to create a key-value pair that results in any value containing any of the keys
will raise anUnsafeSubstitutionErrorThe rationale for the last item is that the keys of thereplacementsfield are strings
that are considered unsafe. Replacing one unsafe string with another defeats the purpose of
using this module.Additionally, if you assign a regulardictto thereplacementsfield, and try to log
something using that configuration,anticrlf.LogFormatterwill reset thereplacementsfield to its default value and issue aUserWarningto that effect.That means the following:formatter.replacements["\n"] = "\\x0A"  # replace LF chars with '\x0A'
del formatter.replacements["\n"]        # return to replacing LF with '\n'
formatter.replacements["\t"] = "\\t"    # replace tabs with '\t'
formatter.replacements["\n"] = "<\t>"   # raises UnsafeSubstitutionErrorThe last occurs because the value<\t>contains\t, which was previously created as a key.And:formatter.replacements = { "\n": "\r" }  # this is a mistake!
logger.info("example")Will result, if that logger is using that formatter, inreplacementsbeing returned to its
safe default value and aUserWarningabout that being issued.
Package: logging-gelf
A python logging bundle to send logs using GELF. This is a rewrote ofDjehoutyQuickstartFirst, install logging-gelf usingpip:pip install -U logging-gelfThe following example shows how to send log in Graylog TCP inputimportloggingfromlogging_gelf.formattersimportGELFFormatterfromlogging_gelf.handlersimportGELFTCPSocketHandlerlogger=logging.getLogger("gelf")logger.setLevel(logging.DEBUG)handler=GELFTCPSocketHandler(host="127.0.0.1",port=12201)handler.setFormatter(GELFFormatter(null_character=True))logger.addHandler(handler)logger.debug("hello !")DocumentationLogging adapter, extra, custom schema and many other stuff are available in the full documentation available athttp://logging-gelf.readthedocs.io/.RequirementsPython >= 3.3Project LinksDocs:http://logging-gelf.readthedocs.io/PyPI:https://pypi.python.org/pypi/logging-gelfIssues:https://github.com/ovh/python-logging-gelf/issuesLicenseLicensed underBSD 3-Clause Licenseorhttps://opensource.org/licenses/BSD-3-Clause.
Package: logging-handler
Python Logging HelperPython library to quickly create logging handlers.  Supports logging to the console as well as to file using a syslog style output format.InstallationThe package is available on PyPi or can be installed manually using the why/tar.gz file attached to the release.pip3 install logging_helperIntroductionThis library provides a function called "create_logger" that will create and return a logging handler that can be used in your application.  The "create_logger" function can be passed a series of different settings to manipulate the default Python logging handler.Examples>>> from logging_helper import create_logger
>>> logger = create_logger(console=True)
>>> logger.warning('test')
2022-11-09 16:09:21,210 - root - WARNING - test
>>>
>>> logger.debug('test debug')
>>> ### Note no output! Default is set to WARNING and above
>>>
>>> logger = create_logger(console=True, console_level='DEBUG')
>>> logger.debug('test debug')
2022-11-09 16:11:13,268 - root - DEBUG - test debug
>>> 
>>> logger2 = create_logger(console=True, console_level='DEBUG', name='log2')
>>> logger2.info('logger2 info!')
2022-11-09 16:12:23,358 - log2 - INFO - logger2 info!
>>> logger.info('logger1 info!')
2022-11-09 16:12:35,510 - root - INFO - logger1 info!In the examples above, you can create multiple loggers with different names.  If a name is not provided, the logger takes on the 'root' logger for Python.  Replacing the 'root' logger will replace the default logging in python and affects other modules.  If you set your logger to debug and start seeing messages from other modules you weren't expecting, provide a name value to your logger.ParametersParameterDefaultDescriptionconsole_level'INFO' (str)Set the logging level for the consoleconsoleTrue (bool)Enable / Disable logging to the consolelog_file'' (str)Set the file to log to (blank means none)file_level'WARNING' (str)Set the logging level for the filefile_mode'a' (str)Feeds into the file mode 'a' for append, 'w' for overwritename'' (str)Name for the logger. Blank will replace the root logging handlersyslogFalse (bool)Send messages to the local system loggersyslog_script_name'' (str)Name to include when using the local system loggerlog_file_vars[] (list)list of variables that can be used to create the log file nameslog_file_retention_days0 (int)Specify the max number of days to retain the log filespropagateFalse (bool)If set to true, the named loggers will also be processed by the root logger.  Generally leave falseRelease Notesv1.0.2- Moved console level to the 1st parameter.  Make it quicker and easier to create a console logger
- Chaned default console level to INFO from WARNING.  This is what I typically end up using anyway
- Updated the home page to our new logging_handler page:https://www.learningtopi.com/python-modules-applications/python_logging_handler/- Allow passing static values DEBUG, INFO, WARNING, ERROR and CRITICAL from the logging module (or you may import from this library)
Package: logging-interceptor
Python Logging InterceptorCapture Python's stdlibloggingmessages and route them to other logging frameworks.(Modified and packaged for PyPI from Matthew Scholefield'sloguru-logging-intercept.)Currently supported targets:LoguruLoguruis a great alternative logging library for Python. However, if you use
(potentially external) code that already integrates with Python's default logger, you'll
get a combination of the two logging styles. This code provides code for setting up an
intercept handler to route calls to Python's defaultloggingmodule to Loguru.UsageBefore calls that use Python's defaultloggingmodule, call the providedsetup_loguru_interceptor()as shown below:fromlogging_interceptorimportsetup_loguru_interceptorsetup_loguru_interceptor(modules=("foo","foo.bar","foo.baz"))# now call functions from `foo` that use getLogger(__name__)InstallationInstall viapip:pip3installlogging-interceptor
Package: logging-journald
logging-journaldPure python logging handler for writing logs to the journald using
native protocol.importloggingfromlogging_journaldimportJournaldLogHandler,check_journal_stream# Use python default handlerLOG_HANDLERS=Noneif(# Check if program running as systemd servicecheck_journal_stream()or# Check if journald socket is availableJournaldLogHandler.SOCKET_PATH.exists()):LOG_HANDLERS=[JournaldLogHandler()]logging.basicConfig(level=logging.INFO,handlers=LOG_HANDLERS)logging.info("Hello logging world.")MESSAGE_IDfieldAs defined incatalog documentation:A128-bitmessage identifier ID for recognizing certain message types, if this is desirable. This should contain a
128-bit ID formatted as a lower-case hexadecimal string, without any separating dashes or suchlike. This is recommended
to be a UUID-compatible ID, but this is not enforced, and formatted differently. Developers can generate a new ID for
this purpose with systemd-id128 new.So you're free to choose how you want to act. By default,MESSAGE_IDis generated as a hash of the message and some
static fields. But you can disable this by passinguse_message_id=Falseto the class constructor.fromlogging_journaldimportJournaldLogHandler...handler=JournaldLogHandler(use_message_id=False)...
Package: logging-k8s-metadata
logging-k8s-metadataEnriches log records with kubernetes metadataGetting startedInstallationInstall library:pipinstalllogging-k8s-metadataUsageCallsetup_logging_k8s_pod_info()method to set up logger factory.Expose k8s metadataLogger factory provided by this lib enriches log records with kubernetes
metadata read from/etc/podinfodirectory which should be exposed by pod. SeeExpose Pod Information to Containers Through Filesfor details.Configure your deployment and add podinfo metadata volume.Exampledeployment.yamlwith metadata volumes:apiVersion:apps/v1kind:Deploymentspec:template:spec:containers:volumeMounts:-name:podinfomountPath:/etc/podinfovolumes:-name:podinfodownwardAPI:items:-path:"name"fieldRef:fieldPath:metadata.name-path:"namespace"fieldRef:fieldPath:metadata.namespace-path:"labels"fieldRef:fieldPath:metadata.labels-path:"annotations"fieldRef:fieldPath:metadata.annotationsDevelopmentFor standalone library development install requirements:pipinstall-rrequirements/dev.txtor install from local repo in developer mode in other project:pipinstall-e../logging-k8s-metadataTestpytestReleaseSet version in git tags to release. Always include a patch version to work
correctly (ex: 1.2.0, even if patch is 0). After git tag is set, CI will build
and publish library on PYPI.
Package: logging_kernel
## logging_kernel===========``logging_kernel`` is an extension of a Jupyter kernel.## Jupyter Version```jupyter --version4.3.0```## Installation------------To install ``logging_kernel`` from PyPI::```pip install logging_kernelpython -m logging_kernel.install```## Using the Logging kernel---------------------**Notebook**: The *New* menu in the notebook should show an option for an Logging notebook.## Installing and Enabling the logging_ext extension### Change your folder to jupyter_extension```cd jupyter_extension```### Install and Enable```rm ~/.jupyter/nbconfig/notebook.json; jupyter nbextension install . --user; jupyter nbextension enable logging_ext;```### You should see the below text if everything goes well```Enabling notebook extension logging_ext...- Validating: OK```## Remove the original python kernel options from the jupyter notebook### Check the kernels with below command```jupyter kernelspec list```### Remove the kernel.json file from the python folder```rm ~/<>/jupyter/kernels/python/kernel.json```# Creating pip package## Create setup.py file```from setuptools import setupsetup(name='my-awesome-helloworld-script',    # This is the name of your PyPI-package.version='0.1',                          # Update the version number for new releasesscripts=['helloworld']                  # The name of your scipt, and also the command you'll be using for calling it)```## Set up PyPi account```python setup.py register```## Create ~/.pypirc file```[distutils]index-servers =pypi[pypi]repository: https://upload.pypi.org/legacy/username:password:```## Upload your package```python setup.py sdist upload```
Package: logging-ldp
A python logging bundle to send logs using GELF on the OVH Logs Data Platform.QuickstartFirst, install logging-ldp usingpip:pip install -U logging-ldpThe following example shows how to send log in Graylog TCP inputimportloggingfromlogging_ldp.formattersimportLDPGELFFormatterfromlogging_ldp.handlersimportLDPGELFTCPSocketHandlerlogger=logging.getLogger("ldp")logger.setLevel(logging.DEBUG)handler=LDPGELFTCPSocketHandler(hostname="gra1.logs.ovh.com")handler.setFormatter(LDPGELFFormatter(token="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"))logger.addHandler(handler)logger.debug("hello !")RequirementsPython >= 3.3Project LinksDocs:http://logging-ldp.readthedocs.io/PyPI:https://pypi.python.org/pypi/logging-ldpIssues:https://github.com/ovh/python-logging-ldp/issuesOVH Logs Data PlatformHomepage (FR):https://logs.ovh.comDocumentation:https://docs.ovh.com/fr/logs-data-platform/Graylog & GELFDocumentation:http://docs.graylog.org/en/latest/pages/gelf.htmlPython logging-gelf:http://logging-gelf.readthedocs.io/LicenseLicensed underBSD 3-Clause Licenseorhttps://opensource.org/licenses/BSD-3-Clause.
Package: logging_levels
As projects get bigger,logging.debug()becomes the dumping
ground for everything that your application is doing. This usually
becomes so noisy that you can’t really make sense of what you’re
trying to debug.Although it is usually disabled in production, sometimes you need to
enable debug logging to – you know – actually debug something. But
sinceeverythingis dumped there, it’s too much of a mess to wade
through.To help with this, you can add extra logging levels. However, rarely
are they added to projects and when they are, they’re often incomplete.
Then sometimes you go to other projects and they’re not there. So you
have to lookup how to add them but usually give up and just stick with
dumping something inlogging.debug()cause you’ll remove it later
– right?What if it was as easy as 2 lines of code to add a new log level?Bam!:fromlogging_levelsimportadd_log_leveladd_log_level(VERBOSE=9)How about a few new log levels?:add_log_level(VERBOSE=9,TRACE=8,NOISE=5,IMPORTANT=100)Now log with them:log.verbose("I've said too much")log.trace("But I haven't said enough")log.noise("That's me in the corner")log.important("That's me in the spotlight")Want to implicitly log exceptions with your fancy new log level?:add_log_level(DANG=90,exceptions=True)try:raiseException('Oops')except:# Will include exception in loglog.dang('Something broke.')Project LoggersBy defualt, logging_levels manipulates the global logging module.
For your projects – especially if you’re creating open source
modules – you should isolate your logging module.fromlogging_levelsimportisolated_logging,log_exceptionslogging=isolated_logging(STUFF=8,THINGS=22,WTF=log_exceptions(1000),)logging.stuff('Log some stuff')logging.wtf('Log some exceptions')If you create this isolated logging module
inmylib/__init__.py, then you can use it throughout your
project easily.frommylibimportlogginglogging.error('Oops, broke something.')StandardsTo help everyone standardize on the same log levels, this library
provides a function to add some missing severity levels defined by the
the syslog protocol inRFC-5424.This library also introduces some additional debugging levels and aSUPPRESSEDlevel which is intended to be used for logging suppressed
exceptions that you may want to log, but otherwise consider handled.Use the functionadd_standardsto add the standard levels provided
by logging-levels:fromlogging_levels.standardsimportadd_standardsimportloggingadd_standards(logging)log.emergency('This aggression will not stand, man.')log.alert('Oh no! Something happened!')log.notice('FYI this other thing happened.')log.verbose('Debug, but so much more')log.trace('Log every -- single -- detail')log.suppressed('Warn a suppressed exception')All levels after usingadd_standardswill be (new levels are bolded):LevelNumeric ValueEMERGENCY100ALERT70CRITICAL50ERROR40SUPPRESSED31WARNING30NOTICE25INFO20DEBUG10VERBOSE7TRACE5NOTSET0Installingpip install logging_levelsTestingInstall dev requirements:pip install -r test.requirements.txtInstall project:pip install -e .Run pytest:py.test tests
Package: logging-nice-handlers
Table of ContentsOverview.Installation via pip:logging HandlersAllLevelFileHandlerJupyterStreamHandlerLinksProject local LinksContactsLicenseOverview.This library consists of different logging handlers which I see usefull in different projects.Installation via pip:pipinstallcharlogging HandlersAllLevelFileHandlerThis handler quite similar to logging.FileHandler but instead of FileHandlerit saves not in one file but in separate file for every levelSo as the results in some directory you will get filesdebug_msgs.txt - For all messages for levels logging.DEBUG and aboveinfo_msgs.txt - For all messages for levels logging.INFO and abovewarning_msgs.txt - For all messages for levels logging.WARNING and aboveerror_msgs.txt - For all messages for levels logging.ERROR and aboveSuch structure of logs can be quite usefull if your projected is expected to be used by externel usersSo in case of some errors all these files with logs can be sent to the author and be analyzed.importloggingfromlogging_nice_handlersimportAllLevelFileHandlerLOGGER=logging.getLogger(__name__)LOGGER.setLevel(10)LOGGER.addHandler(AllLevelFileHandler(str_path_dir_with_logs="Logs",str_open_mode="w",))LOGGER.info("Hi friend!")JupyterStreamHandlerThis handler is the replacement for logging.StreamHandler when it should be used in jupyter notebooksIt will highlight in red all messages with the level which is above some set level.So you won’t miss that the warnings or errors are happening in you programm.importloggingfromlogging_nice_handlersimportJupyterStreamHandlerLOGGER=logging.getLogger(__name__)LOGGER.setLevel(10)LOGGER.addHandler(JupyterStreamHandler(int_min_stdout_level=logging.INFO,int_min_stderr_level=logging.WARNING,))LOGGER.warning("Hi friend!")LinksPYPIreadthedocsGitHubProject local LinksCHANGELOG.CONTRIBUTING.ContactsEmail:stas.prokopiev@gmail.comvk.comFacebookLicenseThis project is licensed under the MIT License.
Package: logging-opentelemetry-format
logging-opentelemetry-formata simple logging formatter which can be used to format logs to opentelemetry specification coming out from a system.
it also provides some additional size control over log body and log attributesInstallationfrom pypipip install logging_opentelemetry_formatUsagecheckexamplefor a complete examplethe formatter is available asfrom logging_opentelemetry_format.utils import OpentelemetryLogFormatteron a basic level this formatter can be added to a logging handlerit takes following optional keyword argumentsuse_traces: use the traces information to enrich logs or not(trace_id and span_id)restrict_attributes_to: list of attributes to which log's attributes should be restricted, any extra attributes passed inside extra keywords in logs will be added against_metainside attributes.meta_character_limit: the max length of value for_metain output logs' attributes, if the length of log's meta exceeds this limit the value of log's meta will be trimmed to specified length. also an attribute_meta_original_lengthis added with value as the length of original log meta and_meta_too_largewith valuetruefor debugging purpose.body_character_limit: the max length of value for log body, if the length of log body exceeds this limit the value of log body will be trimmed to specified value. also an attribute_body_original_lengthis added with value as the length of original log body and_body_too_largewith valuetruefor debugging purpose.discard_attributes_from: an array of attributes which needs to be skipped when exporting logsLocal development and testingbuild the docker-image of the packagedocker-compose build --no-cacherun the imagedocker-compose upgo to the containerdocker exec -it loggingoplttester shto run testspytest tests/to run the actual tests.Licensethis project is licensed underMIT License
Package: logging-plugins
# Handlers, Filters, and other useful plugins for the Python logging systemThis package define a set of util classes to plug as Filters, Handlers and Formatters in yourloggingconfig.## FiltersSkipException: skips logs for given exception classesSkipExceptionMsg: skips logs for given exception classes and matching messages.SkipExceptionMsgRateLimit: same as SkipExceptionMsg but only filters after given rate limit.RateLimiterFilter: rate limit to avoid flooding the handlerOnlyExcFilter: only accepts exception errors (with exc_info)LevelRangeFilter: only accepts records whose levels within a range.## HandlersCounterHandler: doesn’t emits anything, just counts messages by time and records last timestamp.DumpOnSignalCounterHandler: same as CounterHandler but also registers a signal handler and when received dumps the counts to file. Useful for monitoring a process externally (example liveness tests)StoreRecordsHandler: just stores the log records in a list, useful for tests.
Package: logging-process
Example Package这是一个解决多进程下日志丢失的包。
继承自python项目库logging。
所以完全兼容原logging，参数，用法都用变，直接改变类名称即可使用。
具体设置方法可以参考example.py版本更新历史：2021-06-25  0.9.2 第一版正式上传2021-06-25  0.9.3 完善文件结构，可以直接导入logging类2021-06-25  0.9.4 完善example.py示例文件2021-07-14  0.9.5 工作需要，将time rotating 日志名字由时间在后，改为时间在前2021-07-15  0.9.6 增加配置示例2,以时间分割日志文件时，增加参数nameFormat，可自定义文件名拼接方式
Package: logging-profcomff
logging-libБиблиотека для логирования сервисов Твой ФФ!ФункционалФорматирование логов в общий для всех бэкендов JSON-форматСценарий использованияВ requirements.txt добавьте logging-profcomffСкопируйте из /gunicorn_logging_examples обе конфигурацииВставьте их в корень проектаДобаввьте в Dockerfile ARG CONF_FILEВ Dockerfile добавьте GUNICORN_CMD_ARGS в качестве env переменнойПропишите туда "--log-config  $CONF_FILE"В Actions в запуск добавьте(прод) --build-args: docker build --build-arg CONF_FILE=logging_prod.confВ Actions в запуск добавьте(тест) --build-args: docker build --build-arg CONF_FILE=logging_test.confContributingОсновнаяинформацияпо разработке наших приложенийСсылкана страницу с информацией по разработке logging-lib
Package: logging-rate-limiter
logging-rate-limitera simple logging filter which can be used to limit the amount of logs getting out from a system.
It uses token bucket algorithm internally.Installationfrom pypipip install logging_rate_limiterUsagechecktests/test_logging.pyfor a complete exampleon a basic level this filter can be added to a logger or a logging handlerthis filter takes multiple optional keywords with key as log_level and value as a dict with 3 keys"DEBUG": {
    "tokens_per_sec": 1,
    "starting_tokens": 1, # optional, default=0
    "max_tokens_balance": 1 # optional, default=infinity
}tokens_per_sec: the number of tokens(logs) which will be available for a given log levelstarting_tokens: the number of tokens already available at the start of the logging initialisationmax_tokens_balance: the maximum number of tokens that can be accumulated if the logs for a particular level are not being requested as much as thetokens_per_secallowed. kind of limited burst balance.besides providing this config for particular log levels, you can supply adefaultkey with this config.if adefaultis supplied and there is no config supplied for a requested log level then this requested log level will be checked against this default config. useful for scenario where you want an overall rate shared across multiple log levels.besides this an optionalresult_callbackcan be supplied which will be called everytime a log record goes through filter functiontheresult_callbackmust accept 2 paramsresultwhich is a boolean telling whether the log record was filtered or not andrecordthe original log record.Pytestpytest tests/Licensethis project is licensed underMIT License