Skip to content

Commit

Permalink
SantaGUI: Log to syslog
Browse files Browse the repository at this point in the history
  • Loading branch information
russellhancox committed Apr 11, 2016
1 parent 0fceb7b commit 488b28b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions Conf/com.google.santad.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<key>ProgramArguments</key>
<array>
<string>/Library/Extensions/santa-driver.kext/Contents/MacOS/santad</string>
<string>--syslog</string>
</array>
<key>MachServices</key>
<dict>
Expand Down
1 change: 1 addition & 0 deletions Conf/com.google.santagui.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<key>ProgramArguments</key>
<array>
<string>/Applications/Santa.app/Contents/MacOS/Santa</string>
<string>--syslog</string>
</array>
<key>RunAtLoad</key>
<true/>
Expand Down
9 changes: 5 additions & 4 deletions Source/SantaGUI/SNTNotificationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#import "SNTNotificationManager.h"

#import "SNTLogging.h"
#import "SNTStoredEvent.h"

@interface SNTNotificationManager ()
Expand Down Expand Up @@ -75,19 +76,19 @@ - (void)postBlockNotification:(SNTStoredEvent *)event withCustomMessage:(NSStrin
if ([silenceDate isKindOfClass:[NSDate class]]) {
NSDate *oneDayAgo = [NSDate dateWithTimeIntervalSinceNow:-86400];
if ([silenceDate compare:[NSDate date]] == NSOrderedDescending) {
NSLog(@"Notification silence: date is in the future, ignoring");
LOGI(@"Notification silence: date is in the future, ignoring");
[self updateSilenceDate:nil forHash:event.fileSHA256];
} else if ([silenceDate compare:oneDayAgo] == NSOrderedAscending) {
NSLog(@"Notification silence: date is more than one day ago, ignoring");
LOGI(@"Notification silence: date is more than one day ago, ignoring");
[self updateSilenceDate:nil forHash:event.fileSHA256];
} else {
NSLog(@"Notification silence: dropping notification for %@", event.fileSHA256);
LOGI(@"Notification silence: dropping notification for %@", event.fileSHA256);
return;
}
}

if (!event) {
NSLog(@"Error: Missing event object in message received from daemon!");
LOGI(@"Error: Missing event object in message received from daemon!");
return;
}

Expand Down
3 changes: 1 addition & 2 deletions Source/common/SNTLogging.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ void logMessage(LogLevel level, FILE *destination, NSString *format, ...) {
}

// If requested, redirect output to syslog.
if ([[[NSProcessInfo processInfo] arguments] containsObject:@"--syslog"] ||
strncmp(binaryName, "santad", 6) == 0) {
if ([[[NSProcessInfo processInfo] arguments] containsObject:@"--syslog"]) {
useSyslog = YES;
pthread_key_create(&syslogKey, syslogClientDestructor);
}
Expand Down

0 comments on commit 488b28b

Please sign in to comment.