Arrow

Posts on this site are never sponsored.

Logging actions to a file in WordPress

If you’re writing a WordPress plugin, you might want to log certain actions, whether that’s an editing audit log, a specific visitor action, or really anything related to your site. One convenient, accessible, and useful option is to log such activities to a file.

There are several things to consider when logging information to a file, including date-stamping, basic formatting, and maximum log file sizes combined with automatic file rotation (when the log file reaches a certain file size, it is renamed to something like logfile.txt.1 and a new logfile.txt is started). This makes the log activities traceable, easy to read, and manageable on the server.

eZ Publish, an open source, enterprise-grade content management framework, has a general purpose eZLog class that already handles file logging. I’ve very slightly modified it for use within WordPress. Here is an example plugin that logs password change requests (normally sent as e-mails to the site administrator) to a file: peters_file_logs.txt

You can easily re-purpose the eZLog class for your own needs. Its write method simply takes the message to be logged, the log file name, and the path to the log file:

$message = 'Logging this';
$logger = new eZLog();
$logFile = 'wp-logs.txt';
$logPath = WP_CONTENT_DIR;
$logger->write( $message, $logFile, $logPath );

The code above would produce something like the following on a new line in wp-content/wp-logs.txt each time it is run:

[ Aug 21 2010 12:21:07 ] Logging this

You can of course customize the messages logged to add relevant information such as who performed the action, on what page, and so on. You can also customize the maximum number of rotated log files to keep and the maximum size of a log file.

Replacement laptop AC adapters in downtown Vancouver

Unlike with replacement cell phone batteries, I’ve had a couple of bad experiences in buying a replacement AC adapter online. Also, you can probably recognize the need for a replacement cell phone battery well in advance; by contrast, when you need a replacement AC adapter, you often need it as soon as possible.

When I’d forgotten to bring my notebook power cable to work in downtown Vancouver, I first tried by co-workers’ adapters. Unfortunately, while the technical specifications for power adapters are similar for many laptops, the plugs that connect to the different laptops are often of a different shape. (The lack of a standard in this case is quite frustrating.) I then set off on foot to find a replacement. London Drugs was not helpful, instead suggesting that I check out the NCIX store, which is far away and likely doesn’t carry replacement AC adapters. The Source By Circuit City and Future Shop also did not carry what I was looking for.

I ended up at Vancouver Laptop — a store that repairs laptops (and charges you only if they fix your problem) and that sells used laptops. The people there are friendly and helpful. Since they are in the repair business, it makes sense that they had a large selection of replacement adapters in the back. The service person was able to find a compatible adapter within a couple of minutes; a few months later, that adapter is still going strong. The total price including taxes was $60 — quite a bit higher than what I’d found on eBay, but well worth it for the quick, personal, local service, not to mention a durable and effective product!

Replacement cell phone batteries: look on eBay

Cell phone batteries rarely outlast cell phones. Sometimes you don’t properly charge the phone at the very beginning, sometimes it just loses its top charge after years (or less, in some unfortunate cases) of use, or sometimes you’ll purchase a refurbished phone with a mostly dead battery in it. If you can resist the urge to buy a new phone, it’s cheap and easy to get a replacement battery. And the replacement battery might even be better than the original battery was in the very beginning.

Unfortunately, unless you have a fairly popular phone, the usual places — wireless carriers like Rogers, Telus, Bell, etc., London Drugs, Future Shop, Best Buy — might not be of much help. They might simply turn you away or charge you an exorbitant amount with a long wait. Plus, it’s in their best interests to encourage you to buy a new phone.

You don’t have to waste a perfectly good phone because of a non-working battery! Depending on where you are, there are probably some local stores that specialize in replacement batteries. Or, search on eBay. I’ve had several good experiences in buying a replacement cell phone battery on eBay — it was quite cheap (less than $10, including shipping) and lasted longer than the original battery.

Remember to recycle your battery and/or cell phone if you are truly done with them. Or, especially if your phone still works well and takes a SIM card, give away the phone or sell it on Craigslist or this site — it will likely be snapped up in short order.

ING Direct Canada launches *almost* no-fee chequing account

Back in 1997, ING Direct Canada launched an online, high interest savings account which, although was not the first of its kind in Canada, was by far the most well-known and in many ways was an important pioneer. Since then, most other banks have caught up, and ING Direct’s savings rates are not as competitive anymore. I started to wonder whether its slick marketing efforts cancelled out its savings from being an online bank. Also, you’ve always had to pair an ING Direct Investment Savings Account with a chequing account at another bank for full access to your money.

In spite of ING’s middle-of-the-road rates and lack of features, I’ve kept an ING Direct Canada account over the years because of its straightforward, easy-to-use online interface, good customer support, and occasionally decent promotions. Somehow it’s remained just relevant enough. (Why ING Direct Canada’s chequing account took so long to be unveiled is a bit of a mystery, since it has existed in the US for a few years now.) Today it launched a “preview” of its *almost* no-fee chequing account, called the THRiVE Chequing account. By “almost no-fee”, I mean that you still have to pay a small amount for the cheques themselves (after the first 20) and for other typically pay-per-use items such as drafts.

By “preview” I mean that it becomes available for use on September 14, and in its first phase, only to the first 10,000 existing customers who sign up before then. If you’re not already an existing customer, you can open any of its other accounts first (although, be sure to ask as existing customer for their referral code so that you can both get $25), and then immediately apply to get a chequing account. It will be directly available to completely new customers some time in 2011. While the official ING Direct reason for the phased rollout is to finetune the features based on customer feedback, there’s certainly an element of them needing to do more technical testing and of ramping up their internal resources to support such a huge endeavour!

Here are some key features of the ING Direct Canada THRiVE Chequing account. :

  • free to write cheques; first 20 physical cheques are free, but each additional batch of 20 cheques is $10
  • 1 free stop payment per year, then $10 each thereafter
  • free debit
  • free bill payments
  • free withdrawals on EXCHANGE network ATMs, which comprise most credit unions and HSBC ATMs
  • you can go $250 overdraft on your account without penalty as long as you pay it back within 30 days
  • mobile account access
  • customized e-mail alerts
  • free e-mail money transfers; I believe that this is something that many people could benefit from
  • 24/7 phone and e-mail support; there are also a small handful of ING Direct “cafes” where you can talk to someone in-person, although they can’t directly do that much for you
  • $10 for Canadian drafts, including delivery (courier) costs

For a full list of fees, see this page, and for a full account description, see this page.

There is a nominal 0.25% interest rate (higher for balances over $50,000), but you can transfer money to and from an ING Direct Investment Savings Account that has a higher rate.

One thing I’ve always wondered with a fully online bank (or at least one with physical branches that are far away) is what to do if you ever need to deposit a US-dollar cheque. Apparently you can deposit it at an ATM as a Canadian cheque, and later when it’s processed (with something like a 30-day hold), the exchange rate will be applied.

Taking all of the information into account, I think that ING Direct’s new chequing account is an exciting new offering, one that I’ll certainly be trying out. Its feature set is quite complete.

If the THRiVE Chequing account is of interest to you, be sure to consider other options as well. For example, Coast Capital Savings in British Columbia already offers a no-fee chequing account, as does CIBC-owned PC Financial. PC Financial has lower interest rates, fewer features, and a clunkier interface, but does not charge you for the actual cheques.

GoodNews.com review: local Vancouver deals with a charitable twist

GoodNews.com Vancouver officially launches today. The basic concept is simple: every day, there is a local food, adventure, fitness, product, or service deal / coupon for sale for up to 50% to 90% off. A few more details include:

  • It makes use of group purchasing. Businesses can provide the deal because there’s an expectation that there will be at least a certain number of people buying it. In fact, there is usually a minimum number of purchases needed to “activate” the deal. If the deal is not activated, no one is charged. However, I expect that word of GoodNews.com will spread quickly and that almost every posted deal will get activated.
  • It’s time-limited, with a prominently displayed countdown until the deal is no longer available. A big reason for this is that it makes more people want to get in on the “limited time offer”.
  • Once you’ve purchased the deal, you get a coupon to print and bring it in to the relevant establishment.

GoodNews.com Vancouver

If this sounds like Groupon and other deal-of-the-day websites, it’s because a lot of it is very similar. In fact, many of aspects of the GoodNews.com website follow the same model: playful descriptions of the featured businesses, savings percentages, communication methods (they want to e-mail, Twitter, and Facebook you often).

GoodNews.com is different in two ways. First of all, although they have expansion plans outside of Vancouver, they’re from Vancouver. So they’re local, and have a vested interest in supporting local business and a personal interest in seeking out cool deals in their own city.

Secondly, there’s the charity aspect. A portion of every purchase (10% at the moment) made will be donated to a local cause — currently Big Brothers Vancouver — giving money to the cause and also some publicity. (In fact, they are also donating a dollar to Big Brothers for every e-mail subscription sign-up until July 23. This is a good reason to check out GoodNews.com, and you can always unsubscribe!) The next cause is going to be the Celebration of Light. Of course, you could view the charity aspect as just a smart business move: they’re encouraging more people to buy the coupons because of the good cause. But at the end of the day, the charity or other local organization is getting some money that they otherwise wouldn’t have, and in a pretty cool way too.

GoodNews.com has been running in “soft launch” mode for about a week already, so we can already see some examples of what’s been featured: Hub Restaurant and Lounge, a jet ski or sea-doo rental, Piato Estiatoria, Regional Tasting Lounge, pilates, and Bonchaz. Technically there doesn’t have to be only one deal per day, but it’s a model that’s worked and it gets the featured businesses and charities some prominent awareness. I wouldn’t be surprised if down the road GoodNews.com finds a way to feature more than one business at a time. As for the types of deals available, you’ll probably see restaurant and other food deals most often, but I know that GoodNews.com wants to offer a variety of deals and welcomes suggestions.

For most people, taking advantage of GoodNews.com every day is not going to save you money unless you already have a lot of money and thus already go out all the time. Don’t get too caught up in chasing deals — remember that unlike coupon clipping, you actually have to purchase and commit to the deal before you use it! However, following their deals every day is a good way to find out new things about your own city! When you decide to purchase a deal, you’re supporting a local business and a local cause, and probably trying something new.

GoodNews.com is owned by Reinvent, the company with a domain name empire. While I’m not big on pay-per-click domains, it’s good to see them providing value to some of their domain names. And hopefully this means that GoodNews.com has the financial backing to become a solid business.

And a final green note — yes, it’s a bit wasteful to have to print each coupon. For those with smart phones (not me!), I’ve heard that there will be an app in the future!