gnulnx / django-mongolog Goto Github PK
View Code? Open in Web Editor NEWA Simple Mongo Based Logger for Django
Home Page: http://gnulnx.github.io/django-mongolog/
License: GNU General Public License v3.0
A Simple Mongo Based Logger for Django
Home Page: http://gnulnx.github.io/django-mongolog/
License: GNU General Public License v3.0
Check out the python traceback module: https://docs.python.org/2/library/traceback.html
Write some introductory unit tests.
I encountered the following error when I misunderstood the purpose of the logger
argument to Mongolog.find(logger="badger"...)
, where I entered the Mongo collection name badger
instead of the different logger name "mustelidae"
or whatever:
ValueError at /path/to/error/url/
No BaseMongoLogHandler could be found. Did you add on to youy logging config?
Given this:
results = Mongolog.find(
logger='badger',
query={
'msg.jobid': str(jobid),
},
project={
'_id': 0,
'output': '$msg.output',
'jobid': '$msg.jobid',
'cmd': '$msg.cmd'
},
)
If the badger
logger isn't found in Django logging settings, perhaps a more instructive error message would be: "Please check that LOGGERS["loggers"]["badger"]
is defined in your Django settings and that it points to a logging handler of class mongolog.SimpleMongoLogHandler
.
Start a CHANGELOG
Need unit tests for the simple log record format
the ml_purge command assumes localhost when calling mongodump during the backup.
This ticket is to add support for passing in host and port for command and using it in all instances of mongo related calls.
Currently this method only goes two layers deep. This ticket should address this by making it a recursive function that goes 'n' levels deep to replace all keys having a '.' or a '$'.
Currently in setup.py we have:
install_requires=(
'django>=1.7.10',
),
This can almost certainly be a lower version and should be adjusted accordingly.
Get some tests working and hook them up to the travisci
I don't realy know why the
"msg"
doesn't support with python format, eg:%s
,%d
, etc.
I want to record all logs of django request in mongodb,
Here is the result example in mongodb;
But, when I test it in
./manage.py shell
, it worked fine.
@gnulnx, can you correcting my logging please?
Here is my LOGGING
.
import datetime
NOW = datetime.datetime.now()
DAY_NAME = NOW.strftime('%A').lower()
MAXIMUM_FILE_LOGS = 1024 * 1024 * 10 # 10 MB
BACKUP_COUNT = 5
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '[%(levelname)s] %(asctime)s %(name)s: %(message)s'
},
},
'handlers': {
'default': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'logs/default.log',
'maxBytes': MAXIMUM_FILE_LOGS,
'backupCount': BACKUP_COUNT,
'formatter': 'standard',
},
'mongolog': {
'level': 'DEBUG',
'class': 'mongolog.SimpleMongoLogHandler',
# Set the connection string to the mongo instance.
'connection': 'mongodb://localhost:27017',
# define mongo collection the log handler should use. Default is mongolog
# This is useful if you want different handlers to use different collections
'collection': 'mongolog',
'formatter': 'standard',
},
'request_debug_handler': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'logs/request_debug.log',
'maxBytes': MAXIMUM_FILE_LOGS,
'backupCount': BACKUP_COUNT,
'formatter': 'standard',
},
'request_error_handler': {
'level': 'ERROR',
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'logs/request_error.log',
'maxBytes': MAXIMUM_FILE_LOGS,
'backupCount': BACKUP_COUNT,
'formatter': 'standard',
},
'mail_admins_handler': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'email_backend': 'django.core.mail.backends.smtp.EmailBackend'
},
},
'root': {
'handlers': ['default', 'mongolog'],
'level': 'DEBUG'
},
'loggers': {
'django.request': {
'handlers': [
'mongolog',
'request_debug_handler',
'request_error_handler',
'mail_admins_handler'
],
'level': 'DEBUG',
'propagate': False
},
}
}
Take a look at the simple json package and see if it makes sense to use it instead
See this stack discussion: http://stackoverflow.com/questions/712791/what-are-the-differences-between-json-and-simplejson-python-modules
Can we use MongoDB Atlas for this Django mongolog? I've changed my connection URL to the Atlas URL but I got this error when I tried to run my app.
ValueError: Unable to configure handler 'mongolog': No replica set members match selector "Primary()"
Thank you..
Currently in build 0.4.1 the stack trace is shown as a single text entry. It would be better to break this up and show it as an array.
Add a test to ensure that stack trace formatting is alway's an array an not a string.
FAILS: logger.info("Ensuring index %s.%s %s %s", db, col, fields, kwargs)
WORKS: logger.info("Ensuring index %s.%s %s %s" % (db, col, fields, kwargs))
Start a basic LogView class that will eventually grow into a decent interface
title say's it all
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.