Skip to content

Instantly share code, notes, and snippets.

@gdavis

gdavis/GDILog.h

Last active Aug 29, 2015
Embed
What would you like to do?
GDILog - Replacement for NSLog
//
// GDILog.h
// GDILog
//
// Created by Grant Davis on 8/18/14.
// Copyright (c) 2014 Grant Davis Interactive, LLC. All rights reserved.
//
#ifdef DEBUG
#include <string.h>
#define FILE (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define GDILog(...) printf("%s (%d) -> %s\r", FILE, __LINE__, [[NSString stringWithFormat:__VA_ARGS__] UTF8String])
#else
#define GDILog(...)
#endif
@gdavis

This comment has been minimized.

Copy link
Owner Author

@gdavis gdavis commented Aug 18, 2014

GDILog is an alternative to NSLog that provides a few nice things:

  • Remove timestamp and project name
  • Adds the class name and line number the log originated from
  • Disables logging when not in DEBUG mode.
  • Makes a much cleaner and useful print log!
@gdavis

This comment has been minimized.

Copy link
Owner Author

@gdavis gdavis commented Aug 18, 2014

Example:

GDILog(@“Hello, %@!”, @“World”);

Prints:
AppDelegate.m (20) -> Hello, World!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.