Skip to main content
# LogOne

![Logone status](https://img.shields.io/pypi/v/logone.svg)

A simple logger which supports for logging stdout and stderr streams to console, file, and Loggly for Python

## Core Features

+ Simple and easy to use, and also compatible with `logging` package

+ Supports for logging to console, file, and [Loggly](https://www.loggly.com) service in real-time

+ Redirects stdout or stderr stream to the logger as log messages

+ Supports for color and formatting to terminal logging (based on `coloredlogs` package)

+ Works with Python 2 and 3

## Todo

+ [ ] Supports for forwarding logs to Facebook Messenger, Slack, ...

## Installation

`logone` can be installed using [pip](http://www.pip-installer.org):

```
$ [sudo] pip install logone
```

## Example Usage

Here is an example of how easy it is to get started:

```python
#!/usr/bin/python
# -*- coding: utf-8 -*-
import logone

# Indicate `DEBUG` level (or higher) for the root logger
logone.set_level(level=logone.DEBUG)

# Now, we can log anything to the root logger
logone.debug('Quick zephyrs blow, vexing daft Jim')
logone.info('How quickly daft jumping zebras vex')


def main():
# Create a new logger if you do not want to use the root logger
logger = logone.get_logger('example')
logger.set_level(logone.DEBUG)

# Log something to the logger
logger.debug('Debug message')
logger.info('Info message')
logger.warning('Warn message')

# Set up the logger for logging `DEBUG` messages or higher to `example.log` file
# Learn more at: https://docs.python.org/3/library/logging.handlers.html#logging.handlers.TimedRotatingFileHandler
logger.use_file(enabled=True, file_name='logs/example.log', level=logone.DEBUG,
when='d', interval=1, backup_count=10)

# Set up the logger for logging `DEBUG` messages or higher to Loggly service in real-time
logger.use_loggly(enabled=True, level=logone.DEBUG,
loggly_token='YOUR-CUSTOMER-TOKEN', loggly_tag='Python,Example')

# Log something to the logger, file, and Loggly service
logger.error('Error message')
logger.critical('Critical message')

# Redirect stdout stream to the logger as `INFO` messages (for `print` function,...)
logger.redirect_stdout(enabled=True, log_level=logone.INFO)
# Redirect stderr stream to the logger as `ERROR` messages (for unexpected error,...)
logger.redirect_stderr(enabled=True, log_level=logone.ERROR)

# These will be written to stdout stream and then redirected to the logger
print('Jackdaws love my big sphinx of quartz')

value = 20
print('Value = ', value)

# ZeroDivisionError exception will be written to stderr stream and then redirected to the logger
value = 1 / 0
print(value)


if __name__ == '__main__':
main()
```

And here is terminal output:

![Demo](https://raw.githubusercontent.com/dnanhkhoa/logone/master/screenshots/demo.png)

## License

MIT

Metadata

Release files for logone 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for logone 0.1.7
File Size Uploaded
logone-0.1.7.tar.gz 7.3 kB Details

Release files / logone-0.1.7.tar.gz

Download URL logone-0.1.7.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
512c8828dfd8dd39e8adadc0e9cbc2836a86c936261c2d36a7efd82e3680675c
BLAKE2b-256 checksum
How to use checksums
397d69f5e5cdaa2b3c1bc146fc61617a6cc004b3a7890850c5df4facf82399d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.7 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page