2013-04-30 01:15:14 +00:00
|
|
|
/**
|
2014-09-27 05:27:05 +00:00
|
|
|
* Copyright Maarten Billemont (http://www.lhunath.com, lhunath@lyndir.com)
|
|
|
|
*
|
|
|
|
* See the enclosed file LICENSE for license information (LGPLv3). If you did
|
|
|
|
* not receive this file, see http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
|
|
*
|
|
|
|
* @author Maarten Billemont <lhunath@lyndir.com>
|
|
|
|
* @license http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
|
|
*/
|
2013-04-30 01:15:14 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// MPLogsViewController.h
|
|
|
|
// MPLogsViewController
|
|
|
|
//
|
|
|
|
// Created by lhunath on 2013-04-29.
|
|
|
|
// Copyright, lhunath (Maarten Billemont) 2013. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MPLogsViewController.h"
|
|
|
|
#import "MPiOSAppDelegate.h"
|
2013-05-12 18:08:45 +00:00
|
|
|
#import "MPAppDelegate_Store.h"
|
2013-04-30 01:15:14 +00:00
|
|
|
|
2014-09-15 05:00:23 +00:00
|
|
|
@implementation MPLogsViewController
|
2013-08-11 19:30:01 +00:00
|
|
|
|
2013-04-30 01:15:14 +00:00
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
2014-04-20 15:09:49 +00:00
|
|
|
self.view.backgroundColor = [UIColor clearColor];
|
2013-04-30 01:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
2014-09-27 05:27:05 +00:00
|
|
|
PearlAddNotificationObserver( NSUserDefaultsDidChangeNotification, nil, [NSOperationQueue mainQueue],
|
|
|
|
^(MPLogsViewController *self, NSNotification *note) {
|
|
|
|
self.levelControl.selectedSegmentIndex = [[MPiOSConfig get].traceMode boolValue]? 1: 0;
|
|
|
|
} );
|
|
|
|
|
2014-04-20 15:09:49 +00:00
|
|
|
self.logView.contentInset = UIEdgeInsetsMake( 64, 0, 93, 0 );
|
|
|
|
|
2013-04-30 01:15:14 +00:00
|
|
|
[self refresh:nil];
|
|
|
|
|
|
|
|
self.levelControl.selectedSegmentIndex = [[MPiOSConfig get].traceMode boolValue]? 1: 0;
|
|
|
|
}
|
|
|
|
|
2014-09-27 05:27:05 +00:00
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
|
|
|
PearlRemoveNotificationObservers();
|
|
|
|
}
|
|
|
|
|
2013-04-30 01:15:14 +00:00
|
|
|
- (IBAction)toggleLevelControl:(UISegmentedControl *)sender {
|
|
|
|
|
|
|
|
BOOL traceEnabled = (BOOL)self.levelControl.selectedSegmentIndex;
|
|
|
|
if (traceEnabled) {
|
|
|
|
[PearlAlert showAlertWithTitle:@"Enable Trace Mode?" message:
|
2014-09-27 05:27:05 +00:00
|
|
|
@"Trace mode will log the internal operation of the application.\n"
|
|
|
|
@"Unless you're looking for the cause of a problem, you should leave this off to save memory."
|
2013-04-30 01:15:14 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault initAlert:nil
|
|
|
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
|
|
|
if (buttonIndex == [alert cancelButtonIndex])
|
|
|
|
return;
|
|
|
|
|
|
|
|
[MPiOSConfig get].traceMode = @YES;
|
2013-10-31 03:37:12 +00:00
|
|
|
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Enable Trace", nil];
|
2013-04-30 01:15:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
[MPiOSConfig get].traceMode = @NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)refresh:(UIBarButtonItem *)sender {
|
|
|
|
|
|
|
|
self.logView.text = [[PearlLogger get] formatMessagesWithLevel:PearlLogLevelTrace];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)mail:(UIBarButtonItem *)sender {
|
|
|
|
|
2013-04-30 05:49:53 +00:00
|
|
|
if ([[MPiOSConfig get].traceMode boolValue]) {
|
|
|
|
[PearlAlert showAlertWithTitle:@"Hiding Trace Messages" message:
|
2014-09-27 05:27:05 +00:00
|
|
|
@"Trace-level log messages will not be mailed. "
|
|
|
|
@"These messages contain sensitive and personal information."
|
2013-04-30 05:49:53 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault initAlert:nil
|
|
|
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
|
|
|
[[MPiOSAppDelegate get] openFeedbackWithLogs:YES forVC:self];
|
2013-10-31 03:37:12 +00:00
|
|
|
} cancelTitle:[PearlStrings get].commonButtonOkay otherTitles:nil];
|
2013-04-30 05:49:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
[[MPiOSAppDelegate get] openFeedbackWithLogs:YES forVC:self];
|
2013-04-30 01:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|