Package common :: Module logger :: Class Logger
[hide private]
[frames] | no frames]

Class Logger

source code

Instance Methods [hide private]
 
__init__(self) source code
 
close_db(self) source code
 
open_db(self) source code
 
attach_cache_database(self) source code
 
set_synchronous(self, sync) source code
 
init_vars(self) source code
 
simple_commit(self, sql_to_commit)
Helper to commit
source code
 
get_jids_already_in_db(self) source code
 
get_jids_in_db(self) source code
 
jid_is_from_pm(self, jid)
If jid is gajim@conf/nkour it's likely a pm one, how we know gajim@conf is not a normal guy and nkour is not his resource? we ask if gajim@conf is already in jids (with type room jid) this fails if user disables logging for room and only enables for pm (so higly unlikely) and if we fail we do not go chaos (user will see the first pm as if it was message in room's public chat) and after that all okay
source code
 
jid_is_room_jid(self, jid) source code
 
get_jid_id(self, jid, typestr=None)
jids table has jid and jid_id logs table has log_id, jid_id, contact_name, time, kind, show, message so to ask logs we need jid_id that matches our jid in jids table this method wants jid and returns the jid_id for later sql-ing on logs typestr can be 'ROOM' or anything else depending on the type of JID and is only needed to be specified when the JID is new in DB
source code
 
convert_human_values_to_db_api_values(self, kind, show)
Convert from string style to constant ints for db
source code
 
convert_human_transport_type_to_db_api_values(self, type_)
Convert from string style to constant ints for db
source code
 
convert_api_values_to_human_transport_type(self, type_id)
Convert from constant ints for db to string style
source code
 
convert_human_subscription_values_to_db_api_values(self, sub)
Convert from string style to constant ints for db
source code
 
convert_db_api_values_to_human_subscription_values(self, sub)
Convert from constant ints for db to string style
source code
 
commit_to_db(self, values, write_unread=False) source code
 
insert_unread_events(self, message_id, jid_id)
Add unread message with id: message_id
source code
 
set_read_messages(self, message_ids)
Mark all messages with ids in message_ids as read
source code
 
set_shown_unread_msgs(self, msg_id)
Mark unread message as shown un GUI
source code
 
reset_shown_unread_messages(self)
Set shown field to False in unread_messages table
source code
 
get_unread_msgs(self)
Get all unread messages
source code
 
write(self, kind, jid, message=None, show=None, tim=None, subject=None)
Write a row (status, gcstatus, message etc) to logs database
source code
 
get_last_conversation_lines(self, jid, restore_how_many_rows, pending_how_many, timeout, account)
Accept how many rows to restore and when to time them out (in minutes) (mark them as too old) and number of messages that are in queue and are already logged but pending to be viewed, returns a list of tupples containg time, kind, message, list with empty tupple if nothing found to meet our demands
source code
 
get_unix_time_from_date(self, year, month, day) source code
 
get_conversation_for_date(self, jid, year, month, day, account)
Return contact_name, time, kind, show, message, subject
source code
 
get_search_results_for_query(self, jid, query, account)
Returns contact_name, time, kind, show, message
source code
 
get_days_with_logs(self, jid, year, month, max_day, account)
Return the list of days that have logs (not status messages)
source code
 
get_last_date_that_has_logs(self, jid, account=None, is_room=False)
Return last time (in seconds since EPOCH) for which we had logs (excluding statuses)
source code
 
get_room_last_message_time(self, jid)
Return FASTLY last time (in seconds since EPOCH) for which we had logs for that room from rooms_last_message_time table
source code
 
set_room_last_message_time(self, jid, time)
Set last time (in seconds since EPOCH) for which we had logs for that room in rooms_last_message_time table
source code
 
_build_contact_where(self, account, jid)
Build the where clause for a jid, including metacontacts jid(s) if any
source code
 
save_transport_type(self, jid, type_)
Save the type of the transport in DB
source code
 
get_transports_type(self)
Return all the type of the transports in DB
source code
 
iter_caps_data(self)
Iterate over caps cache data stored in the database
source code
 
add_caps_entry(self, hash_method, hash_, identities, features) source code
 
update_caps_time(self, method, hash_) source code
 
clean_caps_table(self)
Remove caps which was not seen for 3 months
source code
 
replace_roster(self, account_name, roster_version, roster)
Replace current roster in DB by a new one
source code
 
del_contact(self, account_jid, jid)
Remove jid from account_jid roster
source code
 
add_or_update_contact(self, account_jid, jid, name, sub, ask, groups, commit=True)
Add or update a contact from account_jid roster
source code
 
get_roster(self, account_jid)
Return the accound_jid roster in NonBlockingRoster format
source code
 
remove_roster(self, account_jid)
Remove all entry from account_jid roster
source code
Method Details [hide private]

__init__(self)
(Constructor)

source code 

close_db(self)

source code 

open_db(self)

source code 

attach_cache_database(self)

source code 

set_synchronous(self, sync)

source code 

init_vars(self)

source code 

simple_commit(self, sql_to_commit)

source code 
Helper to commit

get_jids_already_in_db(self)

source code 

get_jids_in_db(self)

source code 

jid_is_from_pm(self, jid)

source code 
If jid is gajim@conf/nkour it's likely a pm one, how we know gajim@conf is not a normal guy and nkour is not his resource? we ask if gajim@conf is already in jids (with type room jid) this fails if user disables logging for room and only enables for pm (so higly unlikely) and if we fail we do not go chaos (user will see the first pm as if it was message in room's public chat) and after that all okay

jid_is_room_jid(self, jid)

source code 

get_jid_id(self, jid, typestr=None)

source code 
jids table has jid and jid_id logs table has log_id, jid_id, contact_name, time, kind, show, message so to ask logs we need jid_id that matches our jid in jids table this method wants jid and returns the jid_id for later sql-ing on logs typestr can be 'ROOM' or anything else depending on the type of JID and is only needed to be specified when the JID is new in DB

convert_human_values_to_db_api_values(self, kind, show)

source code 
Convert from string style to constant ints for db

convert_human_transport_type_to_db_api_values(self, type_)

source code 
Convert from string style to constant ints for db

convert_api_values_to_human_transport_type(self, type_id)

source code 
Convert from constant ints for db to string style

convert_human_subscription_values_to_db_api_values(self, sub)

source code 
Convert from string style to constant ints for db

convert_db_api_values_to_human_subscription_values(self, sub)

source code 
Convert from constant ints for db to string style

commit_to_db(self, values, write_unread=False)

source code 

insert_unread_events(self, message_id, jid_id)

source code 
Add unread message with id: message_id

set_read_messages(self, message_ids)

source code 
Mark all messages with ids in message_ids as read

set_shown_unread_msgs(self, msg_id)

source code 
Mark unread message as shown un GUI

reset_shown_unread_messages(self)

source code 
Set shown field to False in unread_messages table

get_unread_msgs(self)

source code 
Get all unread messages

write(self, kind, jid, message=None, show=None, tim=None, subject=None)

source code 

Write a row (status, gcstatus, message etc) to logs database

kind can be status, gcstatus, gc_msg, (we only recv for those 3), single_msg_recv, chat_msg_recv, chat_msg_sent, single_msg_sent we cannot know if it is pm or normal chat message, we try to guess see jid_is_from_pm()

We analyze jid and store it as follows:
jids.jid text column will hold JID if TC-related, room_jid if GC-related, ROOM_JID/nick if pm-related.

get_last_conversation_lines(self, jid, restore_how_many_rows, pending_how_many, timeout, account)

source code 
Accept how many rows to restore and when to time them out (in minutes) (mark them as too old) and number of messages that are in queue and are already logged but pending to be viewed, returns a list of tupples containg time, kind, message, list with empty tupple if nothing found to meet our demands

get_unix_time_from_date(self, year, month, day)

source code 

get_conversation_for_date(self, jid, year, month, day, account)

source code 

Return contact_name, time, kind, show, message, subject

For each row in a list of tupples, returns list with empty tupple if we found nothing to meet our demands

get_search_results_for_query(self, jid, query, account)

source code 

Returns contact_name, time, kind, show, message

For each row in a list of tupples, returns list with empty tupple if we found nothing to meet our demands

get_days_with_logs(self, jid, year, month, max_day, account)

source code 
Return the list of days that have logs (not status messages)

get_last_date_that_has_logs(self, jid, account=None, is_room=False)

source code 
Return last time (in seconds since EPOCH) for which we had logs (excluding statuses)

get_room_last_message_time(self, jid)

source code 
Return FASTLY last time (in seconds since EPOCH) for which we had logs for that room from rooms_last_message_time table

set_room_last_message_time(self, jid, time)

source code 
Set last time (in seconds since EPOCH) for which we had logs for that room in rooms_last_message_time table

_build_contact_where(self, account, jid)

source code 
Build the where clause for a jid, including metacontacts jid(s) if any

save_transport_type(self, jid, type_)

source code 
Save the type of the transport in DB

get_transports_type(self)

source code 
Return all the type of the transports in DB

iter_caps_data(self)

source code 

Iterate over caps cache data stored in the database

The iterator values are pairs of (node, ver, ext, identities, features): identities == {'category':'foo', 'type':'bar', 'name':'boo'}, features being a list of feature namespaces.

add_caps_entry(self, hash_method, hash_, identities, features)

source code 

update_caps_time(self, method, hash_)

source code 

clean_caps_table(self)

source code 
Remove caps which was not seen for 3 months

replace_roster(self, account_name, roster_version, roster)

source code 

Replace current roster in DB by a new one

accout_name is the name of the account to change. roster_version is the version of the new roster. roster is the new version.

del_contact(self, account_jid, jid)

source code 
Remove jid from account_jid roster

add_or_update_contact(self, account_jid, jid, name, sub, ask, groups, commit=True)

source code 
Add or update a contact from account_jid roster

get_roster(self, account_jid)

source code 
Return the accound_jid roster in NonBlockingRoster format

remove_roster(self, account_jid)

source code 
Remove all entry from account_jid roster