GithubHelp home page GithubHelp logo

mergifyio / daiquiri Goto Github PK

View Code? Open in Web Editor NEW
333.0 16.0 24.0 169 KB

Python library to easily setup basic logging functionality

License: Apache License 2.0

Python 100.00%
python logging log logging-library hacktoberfest

daiquiri's People

Contributors

blakev avatar chilijohnson avatar davebrochu avatar fridex avatar jcapiitao avatar jd avatar kurtwheeler avatar lamby avatar mergify[bot] avatar mgaitan avatar nsaje avatar sileht avatar tristancacqueray avatar userlerueda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

daiquiri's Issues

Log file shows packages logs and only current app logs

In my app I create a logger using:


def create_logger(log_path, log_name, log_level=logging.INFO):
    daiquiri.setup(
        level=log_level,
        outputs=(daiquiri.output.File(
            directory=log_path, program_name=log_name), 
            daiquiri.output.STDOUT,))

    return daiquiri.getLogger(program_name=log_name)

When I look at the console, I see logs for my app and also for all the packages that I use in my app, before when I used the default logger I didn't see those messages.

Can I turn it off, so that in my log I will only see my app logs?

Uses no color in Jupyter (may need to force TTY)

Daiquiri would also be great to use in Jupyter.
Unfortunately, it seems in Jupyter one usually has to enforce TTY mode in order to make color work.

There does not seem to be an option for that in daiquiri?

Loosing logs in Datadog output

I have a HTTP request that logs using logger.info(...) in three places (no ifs, three lines should always be logged)

I have a datadog output setup like this:

daiquiri.setup(
    outputs=[
        daiquiri.output.Datadog(
            hostname=os.environ["LOGGING_HOST"], port=int(os.environ["LOGGING_PORT"])
        ),
        daiquiri.output.Stream(sys.stdout),
    ],
    level=logging.INFO,
)
logger = daiquiri.getLogger(__name__)

the last logger.info(...) always makes it way do datadog

the first two sometimes do but most of the time don't

Setup default log level an app differently

The root logger and the root logger of the app should be able to be set differently via setup. It's possible one wants to have only warning message for the root logger and the info/debug one for the app being ran.

Logging to journal with a key/value is broken

I'm not sure if I'm doing something wrong, but the following two piece of code generate a exception. I tested versions 1.5.0, 1.6.0 and then 2.1.0 in a clean venv.

daiquiri.setup(level=logging.INFO, outputs=("stdout", "journal"))
logger = daiquiri.getLogger("test", FOO="bar")
logger.info("it works")
daiquiri.setup(level=logging.INFO, outputs=("stdout", "journal"))
logger = daiquiri.getLogger("test")
logger.info("it works", FOO="bar")

The backtrace results in line 92, in emit:

    for k, v in record._daiquiri_extra_keys:
ValueError: too many values to unpack (expected 2)

From what I could see, record._daiquiri_extra_keys was just a tuple of "FOO", without a value, so not sure what's going on there.

[Syslog] no logs into local7

hi,
using Python 3 syslog :

>>> import syslog
>>> syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_LOCAL7)
>>> syslog.syslog("test")

and logs :

$ tail -f /var/log/local7.log
...
Jul  5 15:12:50 cloud-nimbus02-prp python3.4[6636]: test

i try your library using the syslog output :

>>> import daiquiri
>>> daiquiri.setup(outputs=(
...         daiquiri.output.Syslog("cmdb", "LOG_LOCAL7"),
...         daiquiri.output.STDERR,
... ))
>>> logger = daiquiri.getLogger("foo")
>>> logger.info("daiquiri")

There is no log in the local7.log file. Any idea ?

ANSI escape character sequences are printed in Windows cmd.exe when outputting to stderr

I'm stuck using Windows :(for work).

The ANSI escape character sequences are printed in Windows cmd.exe when outputting to stderr.

#test.py
import daiquiri
daiquiri.setup()
logger = daiquiri.getLogger()
logger.error("something went wrong")

test
I can workaround using colorama (the library that IPython uses).

#test_colour.py
import colorama 
colorama.init()

import daiquiri
daiquiri.setup()
logger = daiquiri.getLogger()
logger.error("something went wrong")

test_colour

Colours also work when script is run using ipython as colorama is being used automatically (i.e. ipython test.py).

Is there a way to tell daiquiri not to output colour escape chars?
Even better ; ), would you consider using colorama as an optional extra?

Contrast message from the level

Using this syntax:

import daiquiri, logging
daiquiri.setup()
z = daiquiri.getLogger()
z.warning('abcde')

I get colored output, but the level and message are colored the same. I can
work around it like this:

import daiquiri, logging
daiquiri.setup(outputs=(daiquiri.output.Stream(
   formatter=daiquiri.formatter.ColorFormatter(
      fmt="%(color)s%(levelname)s%(color_stop)s %(message)s"
   )
),))
z = daiquiri.getLogger()
z.warning('abcde')

but I think it would be better to contrast the message from the level. Other
projects color the level only:

from logzero import logger
logger.warning('abcde')

or color the message only:

import coloredlogs, logging
coloredlogs.install()
logging.warning('abcde')

Daiquiri removes all handlers

Hello, the library removes all existing handlers, and that is causing conflicts with third-party libraries, for example click.

When click application is started, i setup logging, and if there are any exceptions in an application, then it just shutdowns silently, because it can not report about crash.

getLogger returning something that is not a logger?

I have the following code:

SH_LOG = daiquiri.getLogger('sh')
SH_LOG.setLevel('WARNING')

This results in a traceback:

Traceback (most recent call last):
  File "/home/lars/env/common/bin/interesting", line 6, in <module>
    from interesting.main import main
  File "/home/lars/projects/interesting/interesting/main.py", line 24, in <module>
    SH_LOG = daiquiri.getLogger('sh')
AttributeError: 'KeywordArgumentAdapter' object has no attribute 'setLevel'

If I replace daiquiri with logging everything works fine.

Running Python 2.7.13.

setuptools warnings

 * QA Notice: setuptools warnings detected:
 * 
 * 	Usage of dash-separated 'author-email' will not be supported in future versions. Please use the underscore name 'author_email' instead
 * 	Usage of dash-separated 'home-page' will not be supported in future versions. Please use the underscore name 'home_page' instead

Make it easier to override the default formatting

Hey,

I really love how you can just do daiquiri.setup() and then just Move On. However, as soon as I would like to change the formatting (ie. drop the process ID and log name as it's always the same) then I end up having something relatively ugly:

formatter = daiquiri.formatter.ColorExtrasFormatter(
   fmt="%(color)s%(levelname).1s: %(message)s%(color_stop)s"
)

daiquiri.setup(outputs=(
    daiquiri.output.Stream(formatter=formatter),
))

Any ideas on making this rather common use-case a bit cleaner? (Perhaps a magic kwarg to daiquiri.setup() like fmt="..."?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.