forked from victorpimentel/TVShows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TVShows_Prefix.pch
64 lines (57 loc) · 2.92 KB
/
TVShows_Prefix.pch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* This file is part of the TVShows 2 ("Phoenix") source code.
* http://github.com/victorpimentel/TVShows/
*
* TVShows is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* You should have received a copy of the GNU General Public License
* along with TVShows. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "LCLLogFile.h"
#endif
// Bundle version of the application
#define TSBundleVersion [[[NSBundle bundleWithIdentifier: CurrentBundleDomain] infoDictionary] \
valueForKey:@"CFBundleVersion"]
#define TSBundleShortVersionString [[[NSBundle bundleWithIdentifier: CurrentBundleDomain] infoDictionary] \
valueForKey:@"CFBundleShortVersionString"]
// TVShows uses parts of LibComponentLogging <http://0xc0.de/LibComponentLogging>.
// Check out the full library for even more awesome power.
#if HELPER_APP
#define LogIdentifier [NSString stringWithFormat:@"[%@ ~ Downloader]", TSBundleVersion]
#else
#define LogIdentifier [NSString stringWithFormat:@"[%@ ~ Main App]", TSBundleVersion]
#endif
// Define the _ts_logger macro
#define _ts_logger(_level, _format, ...) { \
NSAutoreleasePool *_ts_logger_pool = [[NSAutoreleasePool alloc] init]; \
[LCLLogFile logWithIdentifier:[LogIdentifier UTF8String] \
level:_level \
path:__FILE__ \
line:__LINE__ \
function:__PRETTY_FUNCTION__ \
format:_format, \
## __VA_ARGS__]; \
[_ts_logger_pool drain]; \
}
// Define easy to remember logging macros
#define LogCritical(...) _ts_logger(1, __VA_ARGS__)
#define LogError(...) _ts_logger(2, __VA_ARGS__)
#define LogWarning(...) _ts_logger(3, __VA_ARGS__)
#define LogInfo(...) _ts_logger(4, __VA_ARGS__)
#ifdef DEBUG
#define LogDebug(...) _ts_logger(5, __VA_ARGS__)
#define LogTrace(...) _ts_logger(6, __VA_ARGS__)
#else
#define LogDebug(...) do { } while (0)
#define LogTrace(...) do { } while (0)
#endif
// I'm sure that this is entirely unorthodox, but let's make a custom
// localization macro to save us from having to type all this crap in.
#define TSLocalizeString(...) NSLocalizedStringFromTableInBundle(__VA_ARGS__, @"Localizable", [NSBundle bundleForClass:[self class]], nil)