File: debug.lib

package info (click to toggle)
playonlinux 4.3.4-5
  • links: PTS, VCS
  • area: contrib
  • in suites: trixie
  • size: 8,252 kB
  • sloc: sh: 5,390; python: 5,150; ansic: 72; makefile: 57; xml: 47
file content (229 lines) | stat: -rwxr-xr-x 8,079 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/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="$POL_USER_ROOT/logs" # Where the logfile is stored
LOGFILE="/dev/null"  # By default, don't log anything
POL_Color_RedBold='\x1b[1;31m'
POL_Color_BlueBold='\x1b[1;34m' 
POL_Color_YellowBold='\x1b[1;33m'
POL_Color_Reset='\x1b[0m'

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}"
		if [ "$POL_LOGS" -a "$LOGTITLE" ]; then
			if [ -e "$POL_LOGS/$LOGTITLE" ]; then
				rm -rf "$POL_LOGS/$LOGTITLE"
			fi
		fi
		mkdir -p "$POL_LOGS/$LOGTITLE"
		DEBUGGING="$POL_LOGS/$LOGTITLE/"
		LOGFILE="$DEBUGGING/$LOGTITLE.log"
		POL_Debug_Header
	fi
	echo "$POL_COOKIE	POL_SetupWindow_DebugInit	$$	$LOGTITLE" | ncs "$POL_HOST" "$POL_PORT"

}
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 << EOF1 >> "$LOGFILE"
PlayOnLinux debugging tool (v${VERSION})
-----------------------------------------------
Debugging: ${TITLE}

Warning: This is a PlayOnLinux script logfile. It does not contain everything that happened in your program\'s virtual drive (wineprefix)
Please do not use this logfile on winehq forum, this logfile is not interesting for wine debugging.

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
  $(POL_Glxinfo | grep rendering 2> /dev/null)
> glxinfo \| grep renderer
  $(POL_Glxinfo | grep renderer 2> /dev/null)
> OpenGL libs
  $(bash "$PLAYONLINUX/bash/check_gl" x86 stdout)
  $(bash "$PLAYONLINUX/bash/check_gl" amd64 stdout)
> export
  $(export | grep -v -i http_proxy | grep -v POL_PASSWORD)

$1
EOF1
}
POL_Debug_Message()
{
	# Use this function to say something to the person who reads the log file
	# Usage : POL_Debug_Message [MESSAGE]
	
	echo "$(Get_CurrentDate) - [${FUNCNAME[1]}] Message: $@" >> "$LOGFILE"
	echo -e "[${FUNCNAME[1]}] ${POL_Color_BlueBold}Message:${POL_Color_Reset} $@" 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 -e "[${FUNCNAME[1]}] ${POL_Color_YellowBold}Warning:${POL_Color_Reset} $@" 1>&2
}
POL_Debug_ErrorSilent()
{
	# 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 -e "[${FUNCNAME[1]}] ${POL_Color_RedBold}Error:${POL_Color_Reset} $@" 1>&2
	[ "$SETUPWINDOW_INIT" = "true" ] || StandAloneWindow="true"
	[ "$StandAloneWindow" = "true" ] && POL_SetupWindow_Init
	MESSAGE="$(eval_gettext '$APPLICATION_TITLE has encountered an error. If the program does not work correctly, it might be the cause of the problem.\nVisit www.$POL_DNS to get further information')"
	echo "$POL_COOKIE	POL_Debug	$$	$MESSAGE	$TITLE	Error in ${FUNCNAME[1]}\n$(POL_Untab "$@")" | ncns "$POL_HOST" "$POL_PORT"
	[ "$StandAloneWindow" = "true" ] && POL_SetupWindow_Close 
}
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 -e "[${FUNCNAME[1]}] ${POL_Color_RedBold}Error:${POL_Color_Reset} $@" 1>&2
	[ "$SETUPWINDOW_INIT" = "true" ] || StandAloneWindow="true"
	[ "$StandAloneWindow" = "true" ] && POL_SetupWindow_Init
	MESSAGE="$(eval_gettext '$APPLICATION_TITLE has encountered an error. If the program you are installing does not work correctly, it might be the cause of the problem.\nVisit www.$POL_DNS to get further information')"
	echo "$POL_COOKIE	POL_Debug	$$	$MESSAGE	$TITLE	Error in ${FUNCNAME[1]}\n$(POL_Untab "$@")" | ncns "$POL_HOST" "$POL_PORT"
	[ "$StandAloneWindow" = "true" ] && POL_SetupWindow_Close || 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 -e "[${FUNCNAME[1]}] ${POL_Color_RedBold}Fatal:${POL_Color_Reset} $@" 1>&2
	[ "$SETUPWINDOW_INIT" = "true" ] || POL_SetupWindow_Init
	MESSAGE="$(eval_gettext '$APPLICATION_TITLE has encountered a fatal error. $APPLICATION_TITLE will stop the installation process.\nVisit www.$POL_DNS to get further information')"
	echo "$POL_COOKIE	POL_Debug	$$	$MESSAGE	$TITLE	Error in ${FUNCNAME[1]}\n$(POL_Untab "$@")" | ncns "$POL_HOST" "$POL_PORT"
	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
	
	POL_Glxinfo > "$DEBUGGING/glxinfo.log"
}
POL_Debug_InitPrefix()
{
	[ "$POL_OS" = "Linux" ] && POL_Glxinfo 2> /dev/null > "$POL_USER_ROOT/tmp/glxinfo"
	POL_LoadVar_Distro
	PATCHSTUFF="$(POL_Wine_GetPatchName $POL_WINEVERSION)"
	[ ! "$PATCHSTUFF" = "" ] && PATCHSTUFF="Warning! $APPLICATION_TITLE is using a modified wine version ($POL_WINEVERSION).
	Do not file bugs, AppDB test reports, or ask for help on the WineHQ website for any applications or games that are run using this version.
	"
	cat <<- EOF >> "$WINEPREFIX/playonlinux.log"
	
	PlayOn$POL_OS logfile
	-------------------
	Date: $(Get_CurrentDate)
	$PATCHSTUFF
	> PlayOn$POL_OS Version
	  $VERSION
	> uname -a
	  $(uname -a)
	> lsb_release -a
	  $(lsbrelease -a 2> /dev/null)
	> wine --version
	  $(POL_Wine --version)
	> POL_WINEVERSION
	  $POL_WINEVERSION
	> WINEPREFIX
	  $WINEPREFIX
	> Distribution
	  $DISTRO
	> glxinfo \| grep rendering
	  $(cat "$POL_USER_ROOT/tmp/glxinfo" | grep rendering)
	> glxinfo \| grep renderer
	  $(cat "$POL_USER_ROOT/tmp/glxinfo" | grep renderer)
	> OpenGL libs (Direct rendering testing)
	  $("$PLAYONLINUX/bash/check_gl" x86 stdout)
	  $("$PLAYONLINUX/bash/check_gl" amd64 stdout)
	
	EOF
}
POL_Debug_LogToPrefix()
{
	echo "[$(Get_CurrentDate)] - $@" >> "$WINEPREFIX/playonlinux.log"
}
POL_Glxinfo()
{
	if [ "$POL_OS" = "Linux" ] || [ "$POL_OS" = "FreeBSD" ]; then
		glxinfo "$@"
	fi
}