Exemple #1
0
    def _check_journal(self, filename, name, diagnostic):
        lines = [
            "Line 0.",
            "Line 1.",
            "Line 2.",
        ]
        linesLog = [
            "Line 0.",
            "Line 2.",
        ]

        with open(filename, "w") as log:
            journal.logfile(log)
            i = 0
            diagnostic.activate()
            for line in lines:
                diagnostic.log(line)
                diagnostic.flip()

        with open(filename, "r") as log:
            logLines = log.readlines()
            iLog = 0
            for line in linesLog:
                iLog += 1
                self.assertEqual(">> test({name})".format(name=name),
                                 logLines[iLog].strip())
                iLog += 1
                self.assertEqual("-- {line}".format(line=line),
                                 logLines[iLog].strip())
                iLog += 1
        os.remove(filename)
Exemple #2
0
    def configureJournal(self):
        # open the logfile
        stream = file(self.name + '.log', "w")

        # attach it as the journal device
        import journal
        journal.logfile(stream)

        return
Exemple #3
0
    def configureJournal(self):
        # open the logfile
        stream = file(self.name + '.log', "w")

        # attach it as the journal device
        import journal
        journal.logfile(stream)

        return
Exemple #4
0
    def configureJournal(self, path=None):
        if not path: path = self.name + '.log'

        # open the logfile
        stream = file(path, "w")

        # attach it as the journal device
        import journal
        journal.logfile(stream)

        return
    def configureJournal(self, path=None):
        if not path: path = self.name + '.log'
        
        # open the logfile
        stream = file(path, "w")

        # attach it as the journal device
        import journal
        journal.logfile(stream)

        return
Exemple #6
0
def test():
    """
    Send all journal output to a log file
    """
    # get the journal
    import journal

    # send all output to a log file
    journal.logfile(path="api_file_mode.log", mode="a")

    # make a channel
    channel = journal.debug(name="tests.journal.debug")
    # activate it
    channel.activate()
    # add some metadata
    channel.notes["time"] = "now"

    # inject
    channel.line("debug channel:")
    channel.log("    hello world!")

    # all done
    return
Exemple #7
0

# your function
def hello():
    # make a channel
    channel = journal.info("isce3.ampcor.correlate")
    # say something
    channel.log("hello!")
    # all done
    return


# your application main entry point
def main():
    # invoke
    hello()
    # all done
    return


# bootstrap
if __name__ == "__main__":
    # send all output to a logfile
    journal.logfile("hello.log")
    # invoke
    status = main()
    # share the exit code with the shell
    raise SystemExit(status)

# end of file