Tagged logging for Python, Ruby, PHP and Node.js

When I first started working on Amon, my idea was to create an application that can be used both for monitoring servers and as an application log repository - to capture and log exceptions, plus any other data you store in log files. The problem I always had with log files was that they are not flexible - you can’t search in them easily, you are limited to strings and they are hard to manipulate due to their size (even with log rotation).

Amon tries to solve these problems by converting the data you log to JSON and storing it in MongoDB - for easy searching.

# The standard logging behaviour
amon.log('string')

# Ruby
ramon.log(['data','more data'])
ramon.log({:username => 'John', :age => 29 )

# Python 
amonpy.log(['data', 'more data'])
amonpy.log({"username": "John", "age": 29})

# PHP
Amon::log(array('data', 'more data'))

The problem with info, warning, debug, error

We have these levels in almost any programming language, but the problem is they always feel out of place and artificial. You ask yourself, should I log this information with the level ‘debug’; but then in the live application it’s not ‘debug’ anymore, it should be ‘info’. These default levels are especially problematic when working in a team - something could be ‘info’ for you, but ‘warning’ for someone else. The other problem is you never know who logged what.

Amon 0.7 tries to solve this by removing the default tags and replacing them with dynamic ones - so you don’t just log, you can also tag your log data.

# Logging something and adding my name as a tag, for easy searching later
amon.log('log message', 'Martin')

# Or I can add multiple tags that make sense in the spefic case
amon.log('log message', ['Martin', 'user_data', 'debug'])
amon.log('log message', ['John', 'benchmark'])

In the web interface you will see:


You can also log complex datastructures:

image_dictionary={
  "Image": {
        "Width":800,
        "Height":600,
        "Title":"View from 15th Floor",
        "Url": "http://static.amon.cx/3490fdd.png",
        "Thumbnail":
        {
          "Url":"http://static.amon.cx/1232323.png",
          "Height": 125,
          "Width": 100
        }
  }
}

amon.log(image_dictionary, ['Martin','images'])

In the web interface you will see:


You can start tagging your log data by installing Amon curl install.amon.cx | sh and then a client for your programming language - Python, Ruby, PHP, Javascript and Node.js

If you have any questions or suggestions you can leave a comment here. You can also follow Amon on Github.

blog comments powered by Disqus