Ejemplo n.º 1
0
#!/usr/bin/env python3

print("start test")

import g3logPython as log
print("g3logPython imported")

logger = log.get_ifaceLogWorker(False)
journaldSink = logger.SysLogSinks.new_Sink("journald",
                                           "g3logPython_TEST_journald")

print("loggers created")

journaldSink.echoToStderr()

journaldSink.setLogHeader(
    "========== g3logPython TEST journald + journalctl ==========")

print("logger configured")

debug_string = "debug: hello world! from python"
info_string = "some info from python"
warning_string = "important warning from python"

log.debug(debug_string)
log.info(info_string)
log.warning(warning_string)

print("echek journalctl -n50")
Ejemplo n.º 2
0
#!/usr/bin/env python3

import g3logPython as log

logger = log.get_ifaceLogWorker(False)
colorTermSink = logger.LogRotateSinks.new_Sink("log rotate", "py_g3logTest",
                                               "/tmp/")

log.debug("hello world! from python")
Ejemplo n.º 3
0
#!/usr/bin/env python3

import g3logPython
import cppP3Dcalls

logger = g3logPython.get_ifaceLogWorker(False)
colorTermSink = logger.ClrTermSinks.new_Sink("color term")
g3logPython.debug("g3log logger has started")
g3logPython.debug("don't forget to edit /etc/Config.prc")
# TODO: add python builtin logger interoperability

from panda3d.core import Notify, OFileStream, Filename, MultiplexStream

cppP3Dcalls.set_g3log_as_panda3d_backend()

from direct.directnotify.DirectNotify import DirectNotify
from direct.showbase.ShowBase import ShowBase


class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        # Load the environment model.
        self.scene = self.loader.loadModel("models/environment")
        # Reparent the model to render.
        self.scene.reparentTo(self.render)
        # Apply scale and position transforms on the model.
        self.scene.setScale(0.25, 0.25, 0.25)
        self.scene.setPos(-8, 42, 0)
Ejemplo n.º 4
0
#!/usr/bin/env python3 

import g3logPython
import cppP3Dcalls

logger = g3logPython.get_ifaceLogWorker(False)
colorTermSink = logger.ClrTermSinks.new_Sink("color term")
g3logPython.debug("g3log logger has started")
g3logPython.debug("don't forget to edit /etc/Config.prc")
# TODO: add python builtin logger interoperability

from panda3d.core import Notify, OFileStream, Filename, MultiplexStream

cppP3Dcalls.set_g3log_as_panda3d_backend()
g3logPython.debug("g3log set as backend for panda3d's logger")

from direct.directnotify.DirectNotify import DirectNotify
from direct.showbase.ShowBase import ShowBase
 
class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)
        self.exitFunc=self.on_exit
        # Load the environment model.
        self.scene = self.loader.loadModel("models/environment")
        # Reparent the model to render.
        self.scene.reparentTo(self.render)
        # Apply scale and position transforms on the model.
        self.scene.setScale(0.25, 0.25, 0.25)
        self.scene.setPos(-8, 42, 0)
Ejemplo n.º 5
0
 def on_exit(self):
     g3logPython.debug("exit called")
     pass
Ejemplo n.º 6
0
#!/usr/bin/env python3

import g3logPython as g3log
import logging

logger = g3log.get_ifaceLogWorker(False)
colorTermSink = logger.ClrTermSinks.new_Sink("color term")
# optional interoperability with pythons' builtin logger:
builtinLogger = logging.getLogger()
builtinLogger.addHandler(g3log.g3logHandler())
builtinLogger.setLevel(logging.DEBUG)

g3log.debug("hello world! from python, g3log used directly")
logging.info("this message is displayed using python's built-in logger")

Ejemplo n.º 7
0
logger = g3logPython.get_ifaceLogWorker(False)
journaldSink = logger.SysLogSinks.new_Sink("journald", "id=g3log")
logrotateSink = logger.LogRotateSinks.new_Sink("log rotate", "py_g3logTest",
                                               "/tmp/")
colorTermSink = logger.ClrTermSinks.new_Sink("color term")

print("loggers created")

future = journaldSink.setLogHeader("========== TEST HEADER ==========")
future.join()  # optional: join() g3log's worker thread

future = journaldSink.echoToStderr()
future.join()  # optional

future = logrotateSink.setMaxArchiveLogCount(10)
future.join()  # optional

print("logger configured")

g3logPython.debug("debug: hello world! from python")
g3logPython.info("some info from python")
g3logPython.warning("important warning from python")
#g3logPython.fatal("We messed up in python")

# note: sink method calls and logging are asynchronous: the relative chronology
# of their actual execution may not correspond to the relative order in the code.
future = journaldSink.setIdentity("toto")
future.join()  # optional

g3logPython.debug("now with new id")
#!/usr/bin/env python3

print("start test")

import g3logPython as log
import os
import sys

print("g3logPython imported")

logdir_base = "/tmp/g3logPython/"
if not os.path.exists(logdir_base):
    os.mkdir(logdir_base)
logdir1 = logdir_base + "rotate1"
if not os.path.exists(logdir1):
    os.mkdir(logdir1)
logdir2 = logdir_base + "rotate2"
if not os.path.exists(logdir2):
    os.mkdir(logdir2)

logger = log.get_ifaceLogWorker(False)

# new_Sink( g3logPython_sink_name  log_prefix  log_directory )
logrotateSink_1 = logger.LogRotateSinks.new_Sink("log first dir",
                                                 "py_g3logTest_1", logdir1)
logrotateSink_2 = logger.LogRotateSinks.new_Sink("log second dir",
                                                 "py_g3logTest_2", logdir2)

log.debug("two dir test")
Ejemplo n.º 9
0
#!/usr/bin/env python3

import g3logPython as log
import os
import time

logger = log.get_ifaceLogWorker(False)
JournaldSink = logger.SysLogSinks.new_Sink("journald", "g3logPython_Example")

log.debug("hello world! from python (not echoed)")
time.sleep(1)

future = JournaldSink.echoToStderr()
future.join()  # optional: join() g3log's worker thread

log.debug("this string is echoed to stderr")
time.sleep(1)

future = JournaldSink.muteStderr()
future.join()  # optional

log.debug("this string is NOT echoed to stderr")

print("now check your system log with: journalctl _PID=" + str(os.getpid()))
Ejemplo n.º 10
0
#!/usr/bin/env python3

print("start test")

import g3logPython

print("g3logPython imported")

logger = g3logPython.get_ifaceLogWorker(False)
journaldSink = logger.SysLogSinks.new_Sink("journald", "id=g3log")

print("loggers created")

g3logPython.debug("debug: hello world! from python")
g3logPython.info("some info from python")
g3logPython.warning("important warning from python")
g3logPython.fatal("We messed up in python")
Ejemplo n.º 11
0
#!/usr/bin/env python3

#
# full color terminal example
#

import g3logPython as log
import time

logger = log.get_ifaceLogWorker(False)
colorTermSink = logger.ClrTermSinks.new_Sink("color term")

log.debug("hello world! from python")
 # this is required to make sure the text was sent for display before muting:
time.sleep(1)

future = colorTermSink.mute()
future.join()

log.debug("This is not displayed in the terminal")
 # this is required to prevent the sink to be unmuted before the text in sent for display:
time.sleep(1)

future = colorTermSink.unmute()
future.join()

log.debug("this in displayed again")
Ejemplo n.º 12
0
#!/usr/bin/env python3

print("test 05: mixing python and c++")

import g3logPython as log
import cppLib

logger = log.get_ifaceLogWorker(False)
colorTermSink = logger.ClrTermSinks.new_Sink("color term")

log.debug("here we use the logger in python")

cppLib.log_something()

cppLib.add_syslog()

log.debug("from the logger in python again")

cppLib.log_something()

cppLib.log_string("a string from python")