#!/bin/bash # Copyright (C) 2007-2011 PlayOnLinux Team # Copyright (C) 2007-2011 Pâris Quentin # This program 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 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # debug.lib # --------- # # This lib contains PlayOnLinux's debug API POL_LOGS="$REPERTOIRE/logs" # Where are logfile stored LOGFILE="/dev/null" # By default, don't log anything Get_CurrentDate() { # Return the current date date "+%D %T" } POL_Debug_Init() { # Init debugging API. # By calling this function in a script, PlayOnLinux will be able to store all debug information in a logfile, # so that the user can send it to us # Usage : POL_Debug_Init if [ "$TITLE" = "" ] then POL_Debug_Fatal "\$TITLE must be set to use debugging API" else LOGTITLE="${TITLE}_$(date +%s)" mkdir -p "$POL_LOGS/$LOGTITLE" DEBUGGING="$POL_LOGS/$LOGTITLE/" LOGFILE="$DEBUGGING/$LOGTITLE.log" POL_Debug_Header fi } POL_Debug_Header() { # This function permits us to have access to information about the user's computer, # so that we can help him easily # This function is automaticaly called by POL_Debug_Init, you should not use it # Usage : POL_Debug_Header if [ "$WINETRICKS_PKG" ] then WINETRICKS="winetricks packages : $WINETRICKS" fi cat << EOF >> "$LOGFILE" PlayOnLinux debbuging tool (v$VERSION) ----------------------------------------------- Debugging: $TITLE Date: $(Get_CurrentDate) > uname -a $(uname -a) > lsb_release -a $(lsbrelease -a 2> /dev/null) > wine --version (Be careful, this version might not be the version used in the script! Read the content of this file for more information) $(wine --version) > glxinfo \| grep rendering $(glxinfo | grep rendering 2> /dev/null) > glxinfo \| grep renderer $(glxinfo | grep renderer 2> /dev/null) > export $(export | grep -v http_proxy) $1 EOF } POL_Debug_Message() { # Use this function to say something to the person who read the log file # Usage : POL_Debug_Message [MESSAGE] echo "$(Get_CurrentDate) - [${FUNCNAME[1]}] Message: $@" >> "$LOGFILE" echo "[${FUNCNAME[1]}] Message: $@" 1>&2 } POL_Debug_Warning() { # Use this function if you have found a problem that should not have consequences # Usage : POL_Debug_Warning [MESSAGE] echo "$(Get_CurrentDate) - [${FUNCNAME[1]}] Warning: $@" >> "$LOGFILE" echo "[${FUNCNAME[1]}] Warning: $@" 1>&2 } POL_Debug_Error() { # Use this function if a problem occured. # At the end of the script, the user will be able to report a bug to playonlinux's bug tracker # Usage : POL_Debug_Error [MESSAGE] echo "$(Get_CurrentDate) - [${FUNCNAME[1]}] Error: $@" >> "$LOGFILE" echo "[${FUNCNAME[1]}] Error: $@" 1>&2 POL_SetupWindow_message "Error: $@" "$TITLE" # La on affiche quand même export POL_SCRIPT_FAILED="YES" } POL_Debug_Fatal() { # Use this function if a strong problem occured # The effect is the same that POL_Debug_Error, except that the script will end # Usage : POL_Debug_Fatal [MESSAGE] echo "$(Get_CurrentDate) - [${FUNCNAME[1]}] Fatal: $@" >> "$LOGFILE" echo "[${FUNCNAME[1]}] Fatal: $@" 1>&2 POL_SetupWindow_message "[${FUNCNAME[1]}] Fatal: $@" "$TITLE" # La on affiche quand même export POL_SCRIPT_FAILED="YES" POL_SetupWindow_Close exit 1 } POL_Debug_lspci() { # Get information about PCI cards in one's computer # Usage : POL_Debug_lspci lspci > "$DEBUGGING/lspci.log" } POL_Debug_cpuinfo() { # Get information about cpu in one's computer # Usage : POL_Debug_cpuinfo cat /proc/cpuinfo > "$DEBUGGING/cpuinfo.log" } POL_Debug_glxinfo() { # Get information about glx in one's computer # Usage : POL_Debug_glxinfo glxinfo > "$DEBUGGING/glxinfo.log" }