vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Inspired by python logging
2 --
3  
4 GATHERER_NOTIFICATION_PREFIX = 'Gatherer: '
5  
6  
7 Gatherer_ENotificationType = {
8 error = 10,
9 warning = 20,
10 info = 30, sending = 23, receiving = 27,
11 debug = 40
12 }
13  
14  
15 GATHERER_NOTIFICATION_COLORS = {
16 [Gatherer_ENotificationType.error] = {230, 0, 0},
17 [Gatherer_ENotificationType.warning] = {230, 230, 0},
18 [Gatherer_ENotificationType.info] = {60, 200, 230},
19 [Gatherer_ENotificationType.sending] = {107, 140, 230},
20 [Gatherer_ENotificationType.receiving] = {28, 230, 28},
21 [Gatherer_ENotificationType.debug] = {255, 128, 64},
22 }
23  
24  
25 function Gatherer_ChatNotify(str, notificationType)
26 notificationType = notificationType or Gatherer_ENotificationType.info
27  
28 -- by default print info messages and more serious
29 local notificationLevel = Gatherer_ENotificationType.info
30 if Gatherer_Settings.debug then
31 notificationLevel = Gatherer_ENotificationType.debug
32 end
33  
34 if notificationType > notificationLevel then
35 return
36 end
37  
38 local prefix = GATHERER_NOTIFICATION_PREFIX
39 if notificationType == Gatherer_ENotificationType.sending then
40 prefix = prefix..'> '
41 end
42 if notificationType == Gatherer_ENotificationType.receiving then
43 prefix = prefix..'< '
44 end
45  
46 -- usually DEFAULT_CHAT_FRAME is the default "General" chat window
47 if ( DEFAULT_CHAT_FRAME ) then
48 DEFAULT_CHAT_FRAME:AddMessage(
49 prefix..str, unpack(
50 Gatherer_rgbToFloatColor(GATHERER_NOTIFICATION_COLORS[notificationType])
51 )
52 );
53 end
54 end
55