I'm building an installer using pkgbuild and productbuild. I'd like to be able to collect the install logs from my users in the case that anything goes wrong. It'd be nice if those logs were not mixed in with everything else they've installed.
By default it looks like all logs go to /var/logs/install.log. Is there any way to change this location for my app's installer logs?
There are two ways of installing apps in flat file format (.pkg) on MAC OS X:
GUI
Installer.app (On El Capitan it is located in /System/Library/CoreServices/Installer.app) is GUI installer method which doesn't seem to have any option to change the logs but it does have view logs option (Command+L)
Command Line
installer is command line that has -dumplog that can be used to dump logs to stdout that can be redirected to a file.
-dumplog
Detailed log information is always sent to syslog using the LOG_INSTALL facility (and will wind up in /var/log/install.log). -dumplog additionally writes this log to
standard error output.
Command
installer -dumplog -pkg InstallMe.pkg -target / > install.log 2>&1
I ended up solving this by adding the following function to the end of my postinstall script. It detects the first line of install.log that's relevant to the current installation, and copies everything from that line to the end of install.log into a separate file.
One caveat: if multiple installations are happening simultaneously, it's possible to get logs from the other installation mixed in. This solution simply captures a time-bounded snapshot of install.log, but doesn't separate the logs from multiple installations.
function export_log {
NOW=`date "+%Y-%m-%d-%H-%M-%S"`
LOG_NAME="install_log_$NOW.log"
# Interactive install logs start with a line "<AppName> x.x.x Installation Log". Silent install logs start with a line
# "Product archive /path/to/pkg/folder".
# Must include something like \d in this expression and the pkg filename, that won't match this line itself when it's printed in the log
STARTING_LINE_OF_LAST_INSTALL=`egrep '(<AppName> \d+\.\d+\.\d+ Installation Log)|(Product archive.*path/to/pkg/folder/\d+.\d+\.\d+/)' /var/log/install.log | tail -n 1`
# Copy the rest of the log from that line on, up to 10000 lines.
fgrep --after-context=10000 "$STARTING_LINE_OF_LAST_INSTALL" /var/log/install.log > "$LOGGING_DIR/$LOG_NAME"
}
Related
I have created a sample kext used the below code to write a log.
IOLog("scan\n");
I have loaded kext by running below command in terminal.
sudo kextload mykext.kext
it loaded sucessfully when i check system.log file unable to find logs written in code.
You wont be able to find the log file, because there is no such. You should use log utility in terminal:
sudo log show
The output of this command is huge.
There are some built-in options that could help you to filter, like --last 5m, but I recomend to write all your driver messages with some stable prefix, like "MyDriver:", so you can use the log with | grep MyDriver:
We are trying to fetch installer path/name from the MAC UI installer before displaying the Custom nib file.
Below are the options tried:
hdiutil info -plist
Getting the environment variable $PACKAGE_PATH
Scanning the current directory
ps -eaf for listing the installer process name.
I needed to perform the same task today and the best approach I've discovered is to tail or cat the /var/log/install.log file just after the pkg is launched & grep for ".pkg".
tail /var/log/install.log | grep ".pkg"
This prints the path & name of the most recently launched pkg file. From there, I can parse the line of the last occurrence to extract my own installer's path & name:
2022-04-21 12:50:01-04 mbp Installer[29570]: Opened from: /Users/[myuser]/Downloads/[myPkgFile].pkg
2022-04-21 12:50:01-04 mbp Installer[29570]: Product archive /Users/[myuser]/Downloads/[myPkgFile].pkg trustLevel=350
Note: So far, I've only tested this on Big Sur 11.6. The log syntax may differ on older or newer versions. I expect, though, that it hasn't changed much over the years.
I am trying to get the file contents from a specific revision in TEE. According to https://msdn.microsoft.com/en-us/library/gg413270(v=vs.100).aspx the command should be something to the affect of : tf print -version:C1999 Class1.java. This is the error I am receiving:
An argument error occurred: The specified file does not exist at the specified version.
I know I am logged in and my credentials are cached as I am able to query for information like the History command. I also know that the file does exist in this revision as I am getting the information from the history query. Also using Tf.Exe (provided by visual studios) I am able to successfully run :
tf view -version:C1999 Class1.java
and get the contents perfectly fine. Unfortunately for this purpose I am unable to use tf.exe, and it has to the the TEE command line using Tf.Cmd, and they do not support the "view" command.
Any help on getting the file contents would be greatly appreciated.
edit- note I am using the full file path, and, as I said, it works perfectly fine in Tf.exe. Also I have tried using "$/" as the project root and still do not have any success.
Make sure you have installed the latest version of Team Explorer Everywhere.
To use this command, the Read permission on the file that you are
trying to print must be set to Allow.
Even though you could get tf view command to work. Also double check if you have related permission on that specific file.
I have been using TextMate version 2 for MAC from quite some time now, but suddenly yesterday in my code files I am seeing a <CR> tag.
Not sure what the issue is. After doing some googling around I found that it is supposed to be a INVISIBLE character.
But now how do I remove it, can any one suggest any ideas?
Thanks.
Textmate files are set with one of three options..
CR(e.g. Carriage Return or \r) line endings.
LF (e.g. Line Feed or \n)
CRLF (e.g. Carriage Return Line Feed or \r\n)
If a file has inconsistent line endings, Textmate will treat \n as a line ending marker and display <CR> as text.
The issue is caused by a corrupt Launch Services database and can be fixed by running the following command in Terminal and resetting Finder.
sudo /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder
lsregister: [OPTIONS] [-domain { system | local | user | network }]... [path]...
Search the paths for application bundles and add each found item to the Launch
Services database. For domain specifications, ask CF for the list of application
locations in the given domain(s).
-kill Reset the global Launch Services database before doing anything else
-lint Print information about plist errors while registering bundles
-convert Register apps found in older LS database files
-load Load the LaunchServices service plugin if it's not already loaded.
-lazy n Sleep for n seconds before registering apps if the local cache
is aleady populated.
-r Recursively register directory contents, do not recurse into
packages or invisible directories.
-R Recursively register directory contents, including the contents
of packages and invisible directories.
-f force-update registration info even if mod date is unchanged
-v Display progress information.
-dump Display full database contents after registration.
-h Display this help.
Open the file with TextMate, select one <CR>, copy it. Open the "Find" dialogue with the "Regular Expression" option activated. Paste the <CR>, and replace them all with an empty string.
I want to view the log when building an xcode (4.5) project from the command-line, since the output in the command-line window itself is too long and messy. Is there a standard place the logs would go, I can't seem to find them?
There are logs in ~/Library/Developer/Xcode/DerivedData -- you'll have to figure out which sub folder is for your build, but in there is Logs/Build/UUID.xcactivitylog
If you rename that file to a .zip and unzip, there's a text file log in there of the build.
Like all command line tools, output goes to standard output and error goes to standard error. By default this is your command line terminal. Use piping and/or redirection if you want them somewhere else. Check your command line interpreter documentation for more info (probably you are using bash, so check man bash).