Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7642643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:14:30+00:00 2026-05-31T09:14:30+00:00

I am writing a Mobilesubstrate tweak to capture the functions involved in performing a

  • 0

I am writing a Mobilesubstrate tweak to capture the functions involved in performing a particular task on MobileSafari together with the timestamp where its called. I created this tweak and redirected the output to NSLog and saw many of the following message:

process 778 exceeded 500 log message per second limit  -  remaining messages this second discarded

When I used by own log file instead of NSLog, MobileSafari took too long to start and was killed. Is it possible to hook a function and log its function arguments (logify for c based functions) and time/data where its called using a low-overhead method? Is using a custom logging facility possible on iPhone (jailbroken) using and available methods like ASL libraries?

EDIT:
I have tried to work around the problem by creating an NSOperationQueue, an NSOperation called LoggingOperation and embed the class right in the Tweak.xm file. I believe this can relief the main thread to update the UI and complete launching MobileSafari. The tweak can compile but when the function is hit, LoggingOperation did not write to the file, resulting in an empty log file:

//LoggingOperation.h
@interface LoggingOperation : NSOperation {
NSString *event;
}

@property(retain) NSString *Event;

- (id)initWithEvent:(NSString*)ev;

@end

Inside the NSOperation implementation:

//LoggingOperation.m
@implementation LoggingOperation

@synthesize Event;

- (id)initWithEvent:(NSString*)ev;
{
    if (![super init]) return nil;
    [self setEvent:ev];
    return self;
}

- (void)dealloc {
    [Event release], Event = nil;
    [super dealloc];
}

- (void)main {

    NSString *serverError = event;
    if (![[NSFileManager defaultManager] fileExistsAtPath:@"/var/mobile/mylog.log"])
    {
            NSString *statusFileName = [NSString stringWithFormat:@"/var/mobile/mylog.log"];    
            NSFileManager *fileManager = [NSFileManager defaultManager];
            [fileManager createFileAtPath:statusFileName contents:nil attributes:nil];
    }
    serverError = [serverError stringByAppendingString:@"\n"];
    NSString *serverFile = [NSString stringWithFormat:@"/var/mobile/mylog.log"];
    NSData *serverText= [serverError dataUsingEncoding:NSUTF8StringEncoding];
    NSFileHandle *serverFileHandle = [NSFileHandle fileHandleForUpdatingAtPath:serverFile]; 
    if (serverFileHandle)
    {
        [serverFileHandle seekToEndOfFile];
            // this NSLog output appears in syslog but serverText is not written to mylog
        NSLog(@"WRITING TO THE LOG FILE!");
        [serverFileHandle writeData:serverText]; 
        [serverFileHandle closeFile];
    }
}

@end

I also created a convenience method for each hooked method to call to create a log:

void mylog(NSString* serverError)
{
    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    LoggingOperation *op = [[LoggingOperation alloc] initWithEvent:serverError];
    [queue addOperation:op];
    [op release];
}

In the method hook itself:

CGRect replaced_CGRectIntegral (CGRect rect)
{
    mylog(@"CGRectIntegral(rect)");
    return o_CGRectIntegral(rect);
}

I wonder why am I writing to a file in an NSOperation and the file is empty?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:14:32+00:00Added an answer on May 31, 2026 at 9:14 am

    I know it’s not the answer you are looking for, but I would suggest rethinking your logging and reducing the amount of log statements generated. I would be asking the questions why are you logging these things? are they really telling you something important? and if you really need them for a debug session – how can you setup so that the task is only executed once for the test?

    Obviously in a release version you would not have this logging turned on.

    I’ve seen people write custom loggers in the Java world to hook onto method calls and log them and all their parameters. In every case it has been a waste of time because of the massive amount of data produced and the system slow downs generated. Logging is extremely useful when targeted well. It must be concise, contain information that is useful and only generated when there is something worth while to be said.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Writing Classic ASP code in JScript has a lot going for it: more humane
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
Writing documentation in html requires some code examples. What to do with characters that
Writing a python program, and I came up with this error while using the
Writing an asynchronous Ping using Raw Sockets in F#, to enable parallel requests using
Writing a .NET DLL how do I find Application.ProductName ? EDIT: Obviously, importing Windows.Forms
Writing my first C# application...never touched the language before and not much of a
Writing a client application that sends images to a server via a webservice. As
When writing code, I often place debug messages in the code. The debug messages

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.