Skip to main content

Tungl

Project description

Tungl (Islandic for Moon) Logging Library

Tungl is a small portable logging library we wrote internally for some of our projects.

Release Notes

VersionComment
v0.1.5 Bugfixing for NCC compiler.
v0.1.4 Code refactoring.
v0.1.3 Added module and sep options to Python API.
v0.1.2 Lowered requirements to be Python3.6 compatible.
v0.1.1 Added TUNGL_TIME env var.
v0.1.0 Initial Release

How to use?

Tungl can be either be used by directly using the Tungl API:

#include <tungl/api.h>
tungl_log(TUNGL_LEVEL_INFO, "MyModule", __FILE__, __LINE__, "Message %i", variable);

or via the C and C++ macros.

#define L_MODULE "MyModule"
#include <tungl/c.h> // C-style Macros
L_INFO("Message %i", variable);
#define L_MODULE "MyModule"
#include <tungl/cxx.h> // C++-style Macros
L_INFO("Message " << variable);

Available macros (in both API's are):

#define L_STR(...)                       // transforms L_STR(abc) to "abc"
#define L_INFO(...)                      // prints INFO message
#define L_ERROR(...)                     // prints ERROR message
#define L_WARN(...)                      // prints WARN message
#define L_DEBUG(...)                     // prints DEBUG message
#define L_TRACE(...)                     // prints TRACE message
#define THROWAT(MODULE, FILE, LINE, ...) // throws ERROR message and kills the application, reporting FILE and LINE
#define THROW(...)                       // throws ERROR message and kills the application
#define THROWIF(COND, ...)               // throws ERROR message if COND is fulfilled
#define ASSERT(COND)                     // checks COND and prints COND if not successful
#define FAIL()                           // throws "Implementation Error"
#define TODO(...)                        // throws TODO message

or in python!

import tungl
tungl.set_module('my awesome python application')
tungl.get_module()
tungl.set_level(tungl.Level.[ERROR, INFO, WARN, DEBUG, TRACE])
tungl.info ("Message!", file=__file__)
tungl.trace("Message!", file=__file__)
tungl.error("Message!", file=__file__)
tungl.warn ("Message!", file=__file__)
tungl.debug("Message!", file=__file__)
tungl.throw("Message!", file=__file__)
# there is no convenient way to automatically determine the line in Python,
# BUT you can set it manually if you like.

Advanced features

TUNGL_LOG=[INFO, WARN, ERROR, DEBUG, TRACE], tungl_set_level(tungl_log_level_t) or tungl_set_level_str(const char*) can be used to set the log level.

Tungl also supports to write a copy of the log directly to a file using TUNGL_FILE=/any/valid/file/name or tungl_set_file(const char*). All colors will be stripped before writing to the file.

TUNGL_COLOR=OFF can be used to disable color output.

How to build?

python3 -m install illyrian

git clone ...

mkdir tungl/build
cd tungl/build

# Option 1: Local installation (default CMAKE_INSTALL_PREFIX=/usr/local/ve)
illyrian cmake -DTungl_DIST_TYPE=LOCAL ..
cmake --build . --target install

# Option 2: Python package
illyrian cmake -DTungl_DIST_TYPE=PYTHON ..
cmake --build . --target dist

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tungl-0.1.5-py3-none-manylinux_2_17_x86_64.whl (117.5 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

File details

Details for the file tungl-0.1.5-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for tungl-0.1.5-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ecb9258a17ba3eaaeee3733cf371d46c1bf4272d8fa89231038c089410eb0674
MD5 0dc8e41a0349c11afd3d3018e9d5c858
BLAKE2b-256 a6d0a112f624015e27a426cec9b8a4b11f6a6f07673413d7ff46ef143c7c2b08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page