forked from twisted/twisted
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert r42756: Add feature file and nothing else, whoops.
Committed only the topfile. Reopens: twisted#6750 git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@42757 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
- Loading branch information
wsanchez
committed
Jun 3, 2014
1 parent
01b4faf
commit 409d7e6
Showing
59 changed files
with
7,732 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ Developer Guides | |
application | ||
tap | ||
systemd | ||
logger | ||
logging | ||
constants | ||
rdbms | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from twisted.python.logger import Logger | ||
|
||
class AdHoc(object): | ||
log = Logger(namespace="ad_hoc") | ||
|
||
def __init__(self, a, b): | ||
self.a = a | ||
self.b = b | ||
|
||
def logMessage(self): | ||
self.log.info("message from {log_source} " | ||
"where a is {log_source.a} and b is {log_source.b}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import io | ||
from twisted.python.logger import jsonFileLogObserver, globalLogPublisher | ||
from ad_hoc import AdHoc | ||
|
||
globalLogPublisher.addObserver(jsonFileLogObserver(io.open("log.json", "a"))) | ||
|
||
AdHoc(3, 4).logMessage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from twisted.python.logger import extractField | ||
|
||
fmt = ( | ||
"message from {log_source} " | ||
"where a is {log_source.a} and b is {log_source.b}" | ||
) | ||
|
||
def analyze(event): | ||
if event.get("log_format") == fmt: | ||
a = extractField("log_source.a", event) | ||
b = extractField("log_source.b", event) | ||
print("A + B = " + repr(a + b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import io | ||
from twisted.python.logger import eventsFromJSONLogFile | ||
|
||
for event in eventsFromJSONLogFile(io.open("log.json")): | ||
print(sum(event["values"])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import sys | ||
import io | ||
from twisted.python.logger import ( | ||
eventsFromJSONLogFile, textFileLogObserver | ||
) | ||
|
||
output = textFileLogObserver(sys.stdout) | ||
|
||
for event in eventsFromJSONLogFile(io.open("log.json")): | ||
output(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from twisted.python.logger import Logger | ||
|
||
class MyObject(object): | ||
log = Logger() | ||
|
||
def __init__(self, value): | ||
self.value = value | ||
|
||
def doSomething(self, something): | ||
self.log.info( | ||
"Object with value {log_source.value!r} doing {something}.", | ||
something=something | ||
) | ||
|
||
MyObject(7).doSomething("a task") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import io | ||
from twisted.python.logger import eventsFromJSONLogFile | ||
from analyze import analyze | ||
|
||
for event in eventsFromJSONLogFile(io.open("log.json")): | ||
analyze(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from twisted.python.logger import globalLogPublisher | ||
from analyze import analyze | ||
from ad_hoc import AdHoc | ||
|
||
globalLogPublisher.addObserver(analyze) | ||
|
||
AdHoc(3, 4).logMessage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import io | ||
from twisted.python.logger import jsonFileLogObserver, Logger | ||
|
||
log = Logger(observer=jsonFileLogObserver(io.open("log.json", "a")), | ||
namespace="saver") | ||
|
||
def loggit(values): | ||
log.info("Some values: {values!r}", values=values) | ||
|
||
loggit([1234, 5678]) | ||
loggit([9876, 5432]) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.