============
DESCRIPTION
-----------
- 将日志发送到kafka中,做日志分布式管理
INSTALL
-------
ubuntu & windows
>>>>>>>>>>>>>>>>
::
git clone https://github.com/ShichaoMa/log_to_kafka.git
sudo python setup.py install
or
sudo pip install log_to_kafka
HELLOWORLD
----------
demo1
>>>>>
::
from log_to_kafka import Logger
class MyClass(Logger):
name = "log_name"
def __init__(self, settings_file):
super(MyClass, self).__init__(settings_file)
MC = MyClass("default_settings.py")
MC.set_logger()
MC.logger.debug("....")
demo2
>>>>>
::
import os
from log_to_kafka import LogFactory
from cloghandler import ConcurrentRotatingFileHandler
my_dir = "logs"
try:
os.makedirs(my_dir)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
logger = LogFactory.get_instance(name="test_name")
logger.set_handler(
ConcurrentRotatingFileHandler(
os.path.join(my_dir, "test.log"),
backupCount=5,
maxBytes=10240))
logger.info("this is a log. ")
demo3
>>>>>
::
from log_to_kafka import LogFactory, KafkaHandler
settings = {"KAFKA_HOSTS":"192.168.200.90:9092", "TOPIC":"jay-cluster-logs"}
logger = LogFactory.get_instance(name="test_name", json=True)
kafka_handler = KafkaHandler(settings)
logger.set_handler(kafka_handler)
logger.info("this is a log. ")
demo4
>>>>>
::
import sys
import logging
from log_to_kafka import LogFactory
logger = LogFactory.get_instance(name="test_name")
logger.set_handler(logging.StreamHandler(sys.stdout))
logger.info("this is a log. ")
demo5
>>>>>
- 编写自定义handler
- 请参见KafkaHandler的实现方式
Metadata
Release files for log-to-kafka 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| log-to-kafka-1.1.4.tar.gz | 6.6 kB | Without provenance | Details |
Release files / log-to-kafka-1.1.4.tar.gz
| Download URL | log-to-kafka-1.1.4.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a486e38477f98f07a71b686156349765229fbb00ad9f3f2ab2852126cdf59010
|
|
BLAKE2b-256 checksum How to use checksums |
63884fbd0c2b330be5aa2fadd2d56e0cfb11edfae77a1b5b4f3533c42eff49d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for log-to-kafka 1.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.