Saravanan666/pypi-org huggingface dataset:
Package: log-everywhere
log-everywhere Python APIInstalling the packageEnter the following in your command line:# if something isn't working properly, try rerunning this# the problem may have been fixed with a newer versionpip3install-Ulog-everywhere# MacOS/Linuxpipinstall-Ulog-everywhere# WindowsUsing thelog-everywherepackagepython3     # MacOS/Linux
python      # Windowsfromlog_everywhereimportyield_loggerfromlog_everywhereimportlogdefdo_important_things(log_locations):num=1+1log(f'This function calculated num to be:{num}',log_locations)product=num*2log(f'This function calculated the product of num multiplied by 2 to be:{product}',log_locations)log('This function is now closing...',log_locations)defmain():withyield_logger('name_of_my_log_file',log_silently=False)aslog_locations:do_important_things(log_locations)main()To see whyPython Standard Library'sloggingmodule was insufficient and creating a custom logger was necessary,see this modification in theyt_videos_listpackage. NOTE that the exact implementation differed slighlty in this commit (yield_logger()was namedyield_file_writer()), and support for logging to both the console AND the log filewasn't added until this commitDirect link to commits:Simplify logging via custom context manager text writerAlways log to log file but allow console logging mutingTo see more interesting logging modifications, see thesignificantly improves loggingsection nested within thedetailssection of theyt_videos_listpackage0.5.0 Releasepage!Seeingallavailable functions for thelog-everywherepackagepython3     # MacOS/Linux
python      # Windowsimportlog_everywherehelp(log_everywhere.logger)# ORfromlog_everywhereimportloggerhelp(logger)# SEEING PACKAGE METADATAimportlog_everywherehelp(log_everywhere)Usage StatisticsPePyPyPi StatsIf you found this interesting or useful,please consider starring this repoonGitHubso other people can more easily find and use this. Thanks!
Package: log-exec
Installation$[sudo]pipinstalllog-exec$[sudo]npmi-glog-execHow it worksstdout and stderr are duplicated in log files:$LOG_EXEC/<command>/out.log$LOG_EXEC/<command>/err.logConfig$exportLOG_EXEC=~/Library/Logs/log-exec# /usr/local/var/log/log-exec by defaultExamples$log-execscript.shor uselog-execas interpreter:script.sh#!/usr/bin/env log-exec bash...readme42.com
Package: log-ext
py_logging_extensionsa wrapper to provide advanced logging capability with a simple callProvides:coloured logging (If colorama installed)Log to fileconfiguration file is generated for log formats and coloursdifferent log format for levels of logging.DEBUG and belowTRACE logging level added as a level below logging.DEBUG (set to 5)Basic Usageimportlogging# Import and setup the loggerfromlog_extimportsetup_loggersetup_logger()# Create a normal logging instance, and use as per normal docslogger=logging.getLogger('ExampleLogger')logger.setLevel(logging.DEBUG)logger.debug('MyDebugMessage')setup_loggersetup_logger(name='log',base_logger=None,log_dir='logs',cfg_file='log.yaml',config={'date_fmt_str':'%Y-%m-%d_%H:%M:%S','format_str':'%(asctime)17s-%(name)-12s-%(levelname)-8s-%(message)s','detailed_format_str':'(%(module)s-%(funcName)s#%(lineno)d)','colors':{'TRACE':'Back.WHITE,Fore.BLACK','DEBUG':'Fore.CYAN','INFO':'Fore.GREEN','WARNING':'Fore.YELLOW','ERROR':'Fore.RED','CRITICAL':'Back.RED,Fore.WHITE'}},trace_logging=True,clear_others=False,handles=None)Setup a logger (call instead of logging.basicConfig):param name: (String) log file name
:param base_logger: (logging.Logger) logger to base off - uses root if not set
:param log_dir: (string | False) directory to store log files in - doesn't log to file if set to False
:param cfg_file: (string | False) configuration file to use, or false to skip creating a file
:param config: (Dict) configuration dictionary see CONFIG variable for example
:param trace_logging: (Bool) use trace logging
:param clear_others: (Bool) clear existing handlers on the base logger
:param handles: (List) also add these handlers to the base logger
:returns NoneNotesPyinstallerIf using pyinstaller, make sure to provide paths suitable for your install path for log_dir and cfg_file -
if you are using them.clearing handlerssetclear_othersto true to clear any existing handlers.Log filesetlog_dirto false to avoid logging to file.
Package: logextractx
LogExtraCtxThis small humble library is for making logging extra
parameters in logging a bit easier.RationaleI haveblognoteabout it.Usage(look also into docstrings of modules and classes)Pure pythonUsegetLoggerfromlogextractx.logger, and then create local logger with local
context:fromlogextractx.loggerimportgetLoggerlogger=getLogger(__name__)[...]loclogger=logger.local(extra={'DATA_IN':'CURRENT_CONTEXT'})Eg:fromlogextractx.loggerimportgetLoggerlogger=getLogger(__name__)defsend_message(environment:str,requester:str,recipient:str,text:str)->bool:""" Function send_message sends MSG to the specified recipient.  """# extra data to be indexedloclogger=logger.local(extra={'ACTION_TYPE':'SEND_MSG','requester':requester,'recipient':recipient,'user':str(request.user),'environment':env_type})try:r=requests.post(settings.MSG_PROVIDER,json={'recipient':recipient,'content':text},...<otherparams>....)r.raise_for_status()exceptrequests.exceptions.RequestExceptionase:loclogger.error('Sending MSG failed. Response text: "%s"',e)loclogger.debug("headers=%r",r.result.headers)returnFalseloclogger.info('Sending MSG success.')returnTrueDjangoTo tie all log records with commonrequest-idandsession-id, do the following:appendlogextractx.middleware.LogCtxDjangoMiddlewareto yourMIDDLEWAREin settings:MIDDLEWARE=[[...]'django.contrib.sessions.middleware.SessionMiddleware',[...]'logextractx.middleware.LogCtxDjangoMiddleware',]And instead oflogextractx.loggeruselogextractx.middlewareso:fromlogextractx.loggerimportgetLoggerlogger=getLogger(__name__)[...]Also, you need to add filter into logging'filters':{'RidFilter':{'()':'logextractx.middleware.RidFilter'}}And that's all. Now every log entry will containrequest_idandsession_idfields.Django + DjHueyIf you want to also passrequest/session-idto workingHuey/DjHueyby such modifications:Insteadfromhuey.contrib.djhueyimportdb_periodic_task,db_task,taskyou should usefromlogextractx.djhueyimportdb_periodic_task,db_task,taskIf you do so, then all extra context, includingrequest-idandsession-idwill be
passed to logger on the Djhuey side.FlaskLogExtraCtx in Flask is quite similar to usage in Django:fromlogextractx.flaskimportinit_logctxfromlogextractx.middlewareimportgetLogger[...]app=flask.Flask(__name__)app.secret_key="don't tell anyone"init_logctx(app)[...]logger=getLogger(__name__)Extra FormatterIf you use plain logging format, you may be interested in usinglogextractx.formatter.ExtraFormatter.  Just add following in your formatter definition (DictConfig):'formatters':{'simple':{'()':'logextractx.formatter.ExtraFormatter','fmt':'%(levelname)s%(asctime)s%(name)s:%(message)s[%(extras)s]'}}And then you will have all extra in single log line.License:Licensed under the Apache License, Version 2.0
Package: log-factory
# log_factoryThis is a factory for setting up sensible defaults for the python logging module, including:* configuration of format and default level* ability to add a file handler with different log level* helper to set the log level* an ArgumentParser that can be inherited## Usage```pythonimport log_factoryimport logginglog_factory.create()log_factory.set_log_level(logging.DEBUG)log_factory.add_file_handler('out.log')logger = log_factory.get_logger('example')logger.info('hello!')```## InstallationFrom PIP:```bashpip install log_factory```Or pulled from git master:```bashpip install git+https://github.com/colinp85/log_factory```
Package: logfast
LogfastPurposeJust a simple python package which does logging initialization in a certain way.17|12|19|00:18:58|+0100  14474:MainThread  INFO       |__init__.py.21  |   This is an example
17|12|19|00:18:58|+0100  14474:MainThread  WARNING    |__init__.py.22  |   Another oneAs one can see it provides the filename where the log has been created, the Process ID, the Thread Name, and the full time (including timezone).
This is a package I created for my own benefit, as i found myself tired of always doing the same logging initalization.Now i can justpip install logfastwherever i am.Most likely you will want to a have different logging format than me(so this package might be of no use to you).
But if you want the same format feel free to use it.Installationpip install logfastUsage GuideMake sure this is the first module you import in your application.
This makes sure no other call is made first to logging.
Otherwise other modules/libraries might overwrite the logging settings.
This allows you to have multiple application entrypoints but have the same logging configuration.import logfast

logger = logfast.getLogger()


logger.info("This is an example")
logger.warning("Another one")
Package: logfire-python
Logfire - Python Logging Made EasyCollect logs directly from any Python code, including Django.Logfireis a hosted service that centralizes all of your logs into one place. Allowing for analysis, correlation and filtering with SQL. Actionable dashboards and collaboration come built-in. Logfire works withany language or platform and any data source.FeaturesSimple integration. Integrates with the Pythonlogginglibrary.Support for structured logging and events.Automatically captures useful context.Performant, light weight, with a thoughtful design.Supported language versionsPython 3.6.5 or newerpip20.0.2 or newerInstallationInstall the Logfire Python client library using thepipcommand:pipinstalllogfire-pythonMake sure you install thelogfire-pythonpackage and not a different package with thelogfirekeyword in the package name from a different author.Example projectTo help you get started with using Logfire in your Python projects, we have prepared a simple Python program that showcases the usage of Logfire logger.Download and install the example projectYou can download theexample projectfrom GitHub directly or you can clone it to a select directory. Then install thelogfire-pythonclient library as shown before:pipinstalllogfire-pythonRun the example projectTo run the example application, simply run the following command:pythonmain.py<source-token>Don't forget to replace<source-token>with your actual source token which you can find by going to logfire.com -> sources -> edit.If you have trouble running the command above, check your Python installation and try running it with thepython3command instead. It should give you the following output:Output:
All done! You can check your logs now.This example project will create a total of 6 logs. Each corresponding to its respective method.Explore how example project worksLearn how to setup Python logging by exploring the workings of theexample projectin detail.Get in touchHave any questions? Please explore the Logfiredocumentationor contact oursupport.
Package: logfit
The LogFit daemon watches log files and sends data to the LogFit app
for analysis.InstallationTODOUsage# Start in foreground modepython3logfit/client.py[run|foreground]# Start in daemon modepython3logfit/client.pystart# Stop daemonpython3logfit/client.pystop# Restart the daemonpython3logfit/client.pyrestart# Get the daemon statuspython3logfit/client.pystatusConfigurationThe daemon can read from alogfit_config.yamlconfig file of the format:# Required: Get this from your log.fit accountsource:"64a4b9bd88f14511926e0de86f23e2d8"# Optional: The directory the daemon will watchwatch_directory:"/var/log/"# Optional: Minimum log level.  Possible options are# critical, error, warning, info, and debuglog_level:"warning"# Optional: File to write daemon logs tolog_file:"logfit.log"# Optional: limit watching log files to given mime typesallowed_mime_types:-text/plain-inode/x-empty# Optional: List of file globs to not watch, should be the# full absolute pathignore_paths:[]Developmentpythonsetup.pydeveloppipinstall-rrequirements-test.txtflake8coveragerun-munittestcoveragereport-mPublishing# Publish to PyPIpythonsetup.pysdistbdist_wheeltwineuploaddist/*# Generate binaries for multiple operating systemspyinstallerlogfit/main.py-F-plogfit--hidden-importqueue-nlogfit_linux_x86_64pyinstallerlogfit/main.py-F-plogfit--hidden-importqueue-nlogfit_macos_x86_64pyinstallerlogfit/main.py-F-plogfit--hidden-importqueue-nlogfit_windows_x86_64# Copy binaries into logfit-daemon-binary
Package: logfly
logfly  2.4a simple log tool by python.positionlog will create in ./logs/[folder_name]/[date] folder.if use hidden, log will also appear in user/.1o9f1y folder.How toimportimport logflywrite_loglogfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='default-log', hidden='no', color='yes', str_message='yes')Descriptionname: (any str) logfile name, you can use diffrent string to create diffrent logfile.  
where: ('CLI', 'fileCLI', 'file') position where log appear.  
        fileCLI means log will appear in command line window and log file.  
        CLI means log will only appear in command line window.  
        file means log will only appear in logfile.  
info: (any str) custom log level, will upper and wrap with '[]'.  
message: (any str) log message.  
mode: ('add', 'new') default is 'add', means log will add in same day.  
        'new' means logfile will create when program every once.
folder_name: (any str) custom logfly folder name, default is 'default-log'.  
hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder  
color: ('yes', 'no') default is 'yes', means log will with color.  
str_message: ('yes', 'no') default is 'yes', means log will print message with str()create_or_check_filecreate_or_check_file(pathorfile, name, warning='yes'): 
    create or check file.  
    pathorfile: ('file', 'path') choose to create file or path.  
    name: (any str) file or path name.  
    if warning is 'yes', will print warning message if file or path is exist.Descriptionpathfile is the file path that you want to create, must fill with '//'  
filenname is the file name that you want to create, must is with '*.*'
Package: logfmt
LogfmtPython package for parsing log lines in thelogfmtstyle.  See the
original project by Blake Mizerany and Keith Rarick for information
aboutlogfmtconventions and use:https://github.com/kr/logfmtUsing logfmtEasily process lines fromlogfmtformatted input:from logfmt import parse

input = StringIO('\n'.join(['key1=value1', 'key2=value2']))
for values in parse(input):
    print valuesThis program produces this output:{'key1': 'value1'}
{'key2': 'value2'}Easily generate lines inlogfmtformatted outputfrom logfmt import format

for line in format({'key1': 'value1'}, {'key2': 'value2'}):
    print lineThis program produces this output:key1="value1"
key2="value2"InstallationTo install it, simply:pip install logfmt
Package: logfmt1
logfmt1is meant for universal log parsing, whilst reducing manual
configuration or restricting to basic log variants. It handles*.log.fmtfiles to transform LogFormat / placeholder strings to
regular expressions (with named capture groups).{
   "class": "apache combined",
   "record": "%h %l %u %t \"%r\" %>s %b",
}For instance would resolve to:(?<remote_host>[\\w\\-.:]+) (?<remote_logname>[\\w\\-.:]+) (?<remote_user>[\\-\\w@.]+)
\\[?(?<request_time>\\d[\\d:\\w\\s:./\\-+,;]+)\\]? "(?<request_line>(?<request_method>\\w+)
(?<request_path>\\S+) (?<request_protocol>[\\w/\\d.]+))" (?<status>-|\\d\\d\\d)
(?<bytes_sent>\\d+|-)'This python package currently just comes with:.fmtdefinitions for apache + strftime + grok placeholders.logex- a basic log extractorAndupdate-logfmtto create/rewrite*.log.fmtfiles globally.It originated inmodseccfg. You should
ideally install thesystem packagehowever:apt install python3-logfmt1This will yield the proper/usr/share/logfmt/structure and the
run-parts wrapperupdate-logfmt.logfmt1To manually craft a regex:import logfmt1, json
fmt = json.load(open("/.../access.log.fmt", "r"))
rx = logfmt1.regex(fmt)
rx = logfmt1.rx2re(rx)   # turn into Python regexOr with plain old guesswork / presuming a standard log format:rx = logfmt1.regex({"class": "apache combined"})Though that’s of course not the intended use case, and hinges on
predefined formats in /usr/share/logfmt/.logfmt1.logopen()logopen(fn=…)is basically a file-like iterator that yields
dictionaries rather than text strings.for row in logfmt1.logopen(".../access.log"):
print(row["request_time"])And it provides a basic regex/formatstring debugging feature (viadebug=Trueparameter or withlogex-D):failed regex sectionlogexVery crudementary extractor for log files:logex .../access.log --tab @host @date +idWhich also handles the.fmtimplicitly. (Kinda the whole point of
this project.)update-logfmtThe Python package does bundle a run-parts wrapper, but just the apache
collector, and a local Python copy of the format database. It should
discover all (Apache)*.logfiles nonetheless and pair them with.fmtdeclarations.And that’s sort of the main aspect of this project. Establish .log.fmt
files until application vendors come around to making logs parseable.
The rules database structure is subject to change, and only one possible
implementation. There might also be simpler approaches (grok mapping) to
generate regexps for format strings.
Package: logfmt-julian-sobott
Logfmt for pythonLogging Formatter to format log messages inlogfmt format.Logfmt is a simple text-based format for structured logging. It is designed to be easy to read by both humans and machines.
It is also designed to be easy to parse and generate.Example outputts=2022-10-14T17:41:15+0200 lvl=INFO msg="Hello World"Log contextAdditionally, this library supports to add additional information to the log message via LogContexts.
This is also known as MDC (Mapped Diagnostic Context).
This adds values, to the log message across multiple log statements.withLogContext(foo="bar"):logger.info("Hello World")logger.info("This is a second test")logger.info("Outside of context")# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="Hello World" foo=bar# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="This is a second test" foo=bar# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="Outside of context"Installationpipinstalllogfmt-julian-sobottExample usageimportloggingfromlogfmtimportLogFmtFormatter,LogContext,CallableLogContextlogger=logging.getLogger(__name__)logger.setLevel(logging.INFO)formatter=LogFmtFormatter()ch=logging.StreamHandler()ch.setFormatter(formatter)logger.addHandler(ch)logger.info("Hello World")# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="Hello World"logger.info("Hello World",extra={"foo":"bar"})# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="Hello World" foo=barwithLogContext(foo="bar"):logger.info("Hello World")logger.info("This is a second test")logger.info("Outside of context")# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="Hello World" foo=bar# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="This is a second test" foo=bar# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="Outside of context"@CallableLogContext()deffoo(name:str):logger.info("Hello World")foo("bar")# ts=2022-10-14T17:41:15+0200 lvl=INFO msg="Hello World" name=bar@CallableLogContext("name","args")deffoo(name:str,surname:str,*args):logger.info("Hello World")foo("bar with spaces","baz","qux")# ts=2022-10-14T17:45:58+0200 lvl=INFO msg="Hello World" args=('qux',) name="bar with spaces"fromdataclassesimportdataclass@dataclassclassPerson:name:str@CallableLogContext(name="person.name")deffoo(person:Person):logger.info("Hello World")foo(Person(name="Tom"))# ts=2022-10-15T00:56:16+0200 lvl=INFO msg="Hello World" name=Tomtry:raiseException("Something went wrong")exceptExceptionase:logger.exception("trying to fix it")# ts=2022-10-14T22:49:31+0200 lvl=ERROR msg="trying to fix it"# exception="# Traceback (most recent call last):#   File \"/src/tests/x.py\", line 17, in <module>#     raise Exception(\"Something went wrong\")# Exception: Something went wrong"
Package: logfmt-pandas
logfmt-pandasThis package readslogfmtfiles aspandasDataFrames.UsagefromioimportStringIOfromlogfmt_pandasimportread_logfmtdata=StringIO("x=0 y=1\nx=1 y=2")data_frame=read_logfmt(data)TestingRunpoetry run pytestCoverageRunpoetry run pytest --cov
poetry run coverage htmlCoverage report is written tohtmlcov/index.html.
Package: logfollow-server
Real-time web based monitor for your logs.Features(Screenshots are coming…)Real-time updates with WebSocket or other available transportsEasy managable screens and logs, drag-&-drop interfaceListening logs on remote serversWorking with directory listingsExport/import configuration (in progress)Log entries filtering, duplication detect (in progress)InstallUsingPyPIpackage:sudo easy_install logfollow-serverInstall from source:git clone git@github.com:kachayev/logfollow.git
sudo python setup.py install
sudo python setup.py upload_scriptsLaunchStart HTTP server:logfollowd.pyBy defaultlogfollowd.pyserver will listen 8001 port, by use can
specify other port with--portparam. Full list of launching params,
you can find in help message:%> logfollowd.py --help
Usage: /usr/local/bin/logfollowd.py [OPTIONS]

Options:
  --help                           show this help information
  --logging=debug|info|warning|error|none Set the log level.
  --debug
  --gateway_host
  --gateway_port
  --host
  --port
  --templatesIn order to use util without internet connection you have to upload all
necessary JS libraries from CDNs. This can be done:logfollowctl.py upload_scriptsSupervisorSupervisorcan help you with relaunching Logfollow server after critical error and
system reboot. It also provide you with simple console and web-based monitoring
tool for checking server status, reading logs tail and restarting process remotely.You can find more information in Supervisor documentation. Firstly, you should
setup Supervisor and ensure that supervisord daemon in already running:sudo -s
## Generate configuration
logfollowctl.py supervisor_config /etc/supervisor/conf.d/logfollowd.conf

## Restart supervisor in order to spawn new config file
supervisorctl reload

## Check results...
supervisorctl status logfollowd
    logfollowd                       RUNNING    pid 5390, uptime 0:00:13You can also provide list of params forlogfollowd.pylaunching callinglogfollowctl.pyutil:logfollowctl.py supervisor_config --logging=debug --port=8001 --host=127.0.0.1Note that, if don’t use*.conffilename as first param aftersupervisor_configgenerated configuration will be pushed to STDOUT. It can be useful for debuging configuration
file and for using in pipes.ContributorsAlexey S. KachayevVitaliy VilyayTODOUpgrade UIDocumentation and presentation siteExport/import of client-side configurationsFilter and aggregation on client sideConfiguration and customization facilities both from client and with configCross-platform log’s listener implementation for both Linux and Mac OSLicenseLicensed under the Apache 2.0 License.
Seelicensein source code.