dmuth's blog

Log4Go Updates: colored text, Printf(), and SetLevelString()

I recently rolled out some updates for my Log4Go package which I'd like to talk about here.

My first update is the most technically appealing one: Printf()-style functionality.

Instead of having to concatenate strings, percent mark placeholders can be used in the same style as fmt.Printf().

Here are some examples:

log4go.Errorf("Expected 4, got: %d", 72)
log4go.Warn("The temperature in %s is %d degrees and rising!", "Saigon", 112)

The second change I made was the most visually appealing: colored text!

The color of the text printed is now dependent on the severity of the message. Errors are red, Warnings are yellow, Info messages are green, Debug messages are cyan, and Trace messages are purple.

Here is a screenshot of how it looks in Mac OS/X:

Credit where credit is due: I used Meng Zhang's excellent Terminal package for the colored text.

Average: 3.6 (13 votes)
Your rating: None

Introducing Log4Go: Logging for Google Go

When working on my last project, I wanted an easy way to perform logging. I had difficulty finding a logging framework that worked for me, and I figured it would be another good small project if I were to write a log4j-like logger for Google Go.

Here's how to install Log4go:

GOPATH=`pwd` go get # Beginners
go get # Nerds

The latter example assumes that you have the environment variable $GOPATH set. When $GOPATH is set, any packages that are installed will go into a directory hierarchy under that directory. I recommend $HOME/golibs/ as a value for testing and development.

Here's sample usage of Log4go:

import log ""
func main() {

And the output might look something like this:

[301.119ms] INFO: foobar

I wrote some sample tests for Log4go. Here's how to run them:

go test ./src/

And if the test passes, the output should look like this:

ok       0.009s

The source can be downloaded from GitHub:

git clone git://

This project wasn't too terribly complicated, but it gave me some new techniques to try in Google Go. My next project promises to be much more complicated and interesting. Until then, feel free to like, comment, rate, flame or whatever. Smiling

Average: 3 (7 votes)
Your rating: None

Multi Core CPU Performance in GoLang

I've been playing around with Google's programming language known simply as Go lately, and have learned quite a bit about concurrency, parallelism, and writing code to effectively use multiple CPU cores in the process.

An Overview of Go

If you are used to programming at the systems level, Go is effectively a replacement for C, but also has higher level functionality.

  • It is strongly typed
  • It can be compiled
  • It has its own unit testing framwork
  • It has its own benchmarking framework
  • Doesn't support classes, but supports structures and attaching functions to variables instantiated from those structures
  • Doesn't expose threads, but instead uses a construct called "channels" for communication between different parts of a Go program. More on channels shortly.

Your First Go Program

First, let's start with this Go code, which I will walk you through:

    c := make(chan string, config.Buffer_size)

    num_cores := 1
    for i:=0; i<num_cores; i++ {
        go func(c chan string) {

    message := "x"

    for i:=0; i<10000000; i++ {
        c <- message

What this piece of code does is it creates a channel--a construct similar to named pipes in UNIX or SQS queues in Amazon Web Services. One part of code can write to a channel while another piece of the code can read from the same channel and performed a NOOP. It also defines a function inline and precedes it with the keyword "go". That function is then launched in the background as a "goroutine". Goroutines can be thought of as "lightweight threads". Thousands of them can be spawned over the lifetime of a Go program with little impact on performance. If the "num_cores" variable is tweaked in the above code, the run time of the program should decrease as there will be multiple cores reading messages off of the channel. Finally, the code writes the string "x" into the channel 10 million times. Assuming the goroutine is running, the loop to populate the channel should execute on one core while the goroutines which read from the channel should execute on the other cores.

Average: 3.8 (16 votes)
Your rating: None

Furry Connection North 2013 Report

First, the stats.

There were 1,259 total attendees at this year's Furry Connection North.

We raised $21,299.67 for our charity, Country Cat & City Kitty Cat/Kitten Rescue.

As usual, I got to see a lot of friends there, and meet some people I only knew online in person for the first time. Good times all around.

DSC_7143 DSC_7148 DSC_7149 DSC_7152 DSC_7154 DSC_7190

Average: 2.6 (5 votes)
Your rating: None

Notes from "Scaling on AWS for the First 10 Million Users"

Earlier tonight, I had the pleasure of attending a presentation from Chris Munns of Amazon at the offices of First Round Capital about scaling your software on AWS past the first 10 million users. I already had some experience with AWS, but I learned quite a few new things about how to leverage AWS, so I decided to write up my notes in a blog post for future reference, and as a service to other members of the Philadelphia tech community.

Without further preamble, here are my notes from the presentation:

  • "Auto scaling is a tool and a destination"
  • AWS regions are connected via the public Internet, but availability zones in the same region are connected via Amazon-owned fiber. So AZ to AZ communication is entirely across Amazon's infrastructure.
  • More capacity is added to AWS's infrastructure each day than powered all of in 2003. That's a lot of servers.
  • DynamoDB is based on a whitepaper that Amazon wrote back in 2003 or so.
  • DynamoDB is multi-AZ.
  • SQL is a well established technology with clear patterns to scalability (explained further down), and no matter what you think--your data is not special.
  • "Everything fails all the time"
    • Build with that in mind
    • "You cannot have greater than 4 nines in a single data center"
  • Elastic Load Balancers are Availability Zone independent
    • "session stickiness" can route repeat requests from the same person to the same EC2 instance
  • S3 and CloudFront should be used for static assets from your website.
    • This falls under "outsource your infrastructure" -- use Amazon's CDN instead of implementing your own
  • ElasticCache is better than a database for caching (less load) or local files (less invalidation issues)
    • It is hosted Memcache
  • S3 has 11 9s of durability
  • DynamoDB scales really well. Individual customers have done 500,000+ reads/writes with no issue.
  • Auto scaling lets you match capacity to load
Average: 3.3 (6 votes)
Your rating: None

An American's Visit to Sweden and Denmark

I found myself between jobs a short awhile ago, and suddenly had a few weeks of downtime. Since I had an open invitation to visit Sweden and Denmark from friends living there, I figured I would take the opportunity and head over. I took a few pictures, and noted some observations about those countries.

First, Know Some Locals

If you want to take a package tour and see the parts of the country that are tourist attractions, feel free. But you'll get much more out of the experience if you know locals who can show you things that they think are interesting. I was fortunate to know both Pinky Fennec and Joel Fox, who were more than happy to host me while I visited.

Public Transit is Amazing

A subway station on the Hågsatra line

The train system in Stockholm is pretty extensive. Trains and busses run pretty much everywhere you'd want to go. Both systems used a wireless card that you could buy with a week's worth of fare, and just swipe it at the turn style or at the front of the bus. Subway stations had displays above the tracks stating how much time until the next train would arrive. When bus schedules said that busses arrived on the quarter of every hour, they meant it.

It was also pretty much the same in Copenhagen, except I spent more time on busses. The bus service there was simply phenomenal. They had busses that would arrive every 8 minutes, and they meant it. I regularly commuted from a friend's place on the outskirts of Copenhagen to the central part of the city every single day.

Getting from city to city was also fun. I rode on what amounted to the Swedish version of Amtrak from Stockholm to Copenhagen. It was a single train ride, about 400 miles in 5 hours. That's an average of 80 mph, but with the stops we made I'd say we did somewhere between 90 and 100 mph most of the time. The train ride was exceptionally smooth, and several times when we started moving I thought that the train next to us was moving. Naturally, these trains were also on time.

Danish Cheetah
This Danish cheetah tried to sell me a scarf!

Public transit here in the US could learn a few things from how they do it in these two cities.

Be Prepared to Walk Everywhere

What comes with taking lots of public transit? Lots of walking. Be ready to walk everywhere. This is actually a good thing, because of the benefits of the exercise it provides. One thing I noticed in both countries was pretty much a total lack of obesity in the native populations. This was especially noteworthy given the amount of drinking I saw in both countries.

Denmark Has Amazing Pastries

My first morning in Denmark, Pinky said "BRB" and ran a half-block down the street to the local bakery. She returned with a bundle of amazing pastries that were no more than a few hours old. They made for an amazing breakfast.

I wish I could remember what these delicious pastries were called, but I do know that the Danish just can't get enough of them!

Average: 3.3 (6 votes)
Your rating: None

So I got invited to try out Google Glass

"Whoa. This is heavy."

So I got invited to try out Google Glass the other day. I'm looking forward to this, since this something that really hasn't been done before, at least not in the "voice-activated computer glasses with an Internet connection" sense.

A few ideas that I'm thinking of using the glasses for:

  • Using facial recognition on my friends, possibly with GPS
  • Hitting SEPTA's website to see what the next train to leave is.
  • Finding my way around new parts of Philadelphia. (the nicer parts, that is Eye-wink )
  • Streaming portions of Anthrocon
  • Taking some "behind the scenes" video of the setup in the days before Anthrocon, or during setup at the convention itself.

Have your own suggestions for how I should use the glasses? Let me know in the comments!

Average: 2.4 (7 votes)
Your rating: None

The Cira Centre on a Cloudy Day

I took some pictures of the Cira Centre while walking around Philadelphia today:

The Cira Centre The Cira Centre
The Cira Centre The Cira Centre

The Regional Rail section of 30th Street Station can be seen in the foreground.

Anyway, like... favorite... let me know what you think in the comments!

Average: 3.4 (7 votes)
Your rating: None

Running Dorsai Thing 2013: Lessons Learned

Dinner on Saturday Evening

Each year, The Dorsai Irregulars have their own annual convention known as "Dorsai Thing". It is a weekend long event, held in a different city each year, where we all gather, socialize, and hold our semi-annual business meeting. This year, it was held in Phildelphia, and it fell on my shoulders to run the event, dubbed "Liberty Thing" While I've worked at plenty of conventions before, this was the first one where I was effectively the Con Chair. This was an entirely new thing for me, and I wanted to write a blog post about some of the things I learned during the experience.

Don't Procrastinate!

It's easy to let things slide when you're several months out from the convention. But remember, you never know when life is going to throw you a curveball that eats up your spare time. In my case, a job change combined with my bank failing suddenly began to eat up a lot of my free time, and it left me feeling under pressure to get things done. The lesson here is to try and get things out of the way early.

Hotels: Get a Small Room Block

A room block is a guarantee of room nights that you will give the hotel during the convention. If the hotel doesn't sell enough room nights to fill the block, they will often reserve the right to come after you for the difference in revenue. This sounds harsh, but remember that if a hotel does not rent a room for a given night, that's lost revenue which it will never be able to regain. Hotels really don't like empty rooms. Smiling

In my case, I contracted a room block of 40 nights. We ended up renting nearly twice as many rooms. The hotel really liked that!

Average: 2.6 (5 votes)
Your rating: None

Setting up IPv6 on Linode with nginx

So Linode has gotten onto the IPv6 bandwagon. In addition to each Linode getting an IPv6 address, they will also gladly assign an entire /64 netblock to your specific node on request. That gives you all sorts of flexibility for bringing up IPv6 services. And this blog post is going to be all about how to make use of multiple IPv6 addresses.

As of this writing, everything I mention will work on a Linode running Ubuntu 12.04 LTS and Nginx 1.1. There's no reason that these instructions shouldn't work on other distros or versions of Ubuntu with some modifications.

Setting An IPv6 Address

Warning: You're playing around with networking settings. If something goes wrong, your Linode could find itself unreachable from the network and you'll need to reboot it. And that's not fun. I strongly recommend proceeding through the LISH console so that you can undo any mistakes you make.

To start with, send a support request to Linde and get your /64 assigned. For the purposes of this post, let's assume you get the subnet 2600:3000:4000:1000/64. That will give you a range of 2^64 addresses from 2600:3000:4000:1000:0:0:0:0 to 2600:3000:4000:1000:ffff:ffff:ffff:ffff. That should be plenty of addresses to work with. Eye-wink

To bring up one of those addresses, run this command:

ip -6 addr add 2600:3000:4000:1000::100/64 dev eth0

The address should now show up when you run ip -6 addr show eth0, and you should be able to use the ping6 utility to ping 2600:3000:4000:1000::100. If ping6 is not working, then something is wrong.

$ ip -6 addr show eth0
3: eth0:  mtu 1500 qlen 1000
    inet6 2600:3000:4000:1000::100/64 scope global 
       valid_lft forever preferred_lft forever

Average: 2.6 (15 votes)
Your rating: None