Commit 0bb85b7d authored by Claes Sjofors's avatar Claes Sjofors

Username added to history log

parent b564b91f
...@@ -35,10 +35,15 @@ CoLog *CoLog::m_default_log = 0; ...@@ -35,10 +35,15 @@ CoLog *CoLog::m_default_log = 0;
void CoLog::log( const char *category, const char *str, const char *cmt, unsigned int opt) void CoLog::log( const char *category, const char *str, const char *cmt, unsigned int opt)
{ {
ofstream fp; ofstream fp;
pwr_tStatus sts;
char timstr[40]; char timstr[40];
char username[80];
char comment[200] = ""; char comment[200] = "";
time_AtoAscii( 0, time_eFormat_DateAndTime, timstr, sizeof(timstr)); time_AtoAscii( 0, time_eFormat_DateAndTime, timstr, sizeof(timstr));
sts = syi_UserName( username, sizeof(username));
if ( EVEN(sts))
strcpy( username, "Unknown");
if ( cmt) if ( cmt)
strncpy( comment, cmt, sizeof(comment)); strncpy( comment, cmt, sizeof(comment));
...@@ -72,6 +77,10 @@ void CoLog::log( const char *category, const char *str, const char *cmt, unsigne ...@@ -72,6 +77,10 @@ void CoLog::log( const char *category, const char *str, const char *cmt, unsigne
for ( int i = strlen(category); i < 11; i++) for ( int i = strlen(category); i < 11; i++)
fp << " "; fp << " ";
fp << " "; fp << " ";
fp << " " << username;
for ( int i = strlen(username); i < 11; i++)
fp << " ";
fp << " ";
fp << str; fp << str;
if ( strcmp( comment, "") != 0) if ( strcmp( comment, "") != 0)
fp << " \"" << comment << "\""; fp << " \"" << comment << "\"";
...@@ -80,11 +89,11 @@ void CoLog::log( const char *category, const char *str, const char *cmt, unsigne ...@@ -80,11 +89,11 @@ void CoLog::log( const char *category, const char *str, const char *cmt, unsigne
} }
void CoLog::get( char categories[][20], char *item, void CoLog::get( char categories[][20], char *item,
void item_cb( void *, pwr_tTime, char *, char *, char *), void *ctx) void item_cb( void *, pwr_tTime, char *, char *, char *, char *), void *ctx)
{ {
ifstream fp; ifstream fp;
char line[1024]; char line[1024];
char line_array[7][512]; char line_array[8][512];
int parts; int parts;
int num; int num;
unsigned int level; unsigned int level;
...@@ -100,8 +109,8 @@ void CoLog::get( char categories[][20], char *item, ...@@ -100,8 +109,8 @@ void CoLog::get( char categories[][20], char *item,
sizeof( line_array[0]), 0); sizeof( line_array[0]), 0);
if ( item && if ( item &&
!(item[strlen(item)-1] == '*' && cdh_NoCaseStrncmp( line_array[5], item, strlen(item)-1) == 0) && !(item[strlen(item)-1] == '*' && cdh_NoCaseStrncmp( line_array[6], item, strlen(item)-1) == 0) &&
cdh_NoCaseStrcmp( line_array[5], item) != 0) cdh_NoCaseStrcmp( line_array[6], item) != 0)
continue; continue;
int found = 0; int found = 0;
...@@ -125,10 +134,10 @@ void CoLog::get( char categories[][20], char *item, ...@@ -125,10 +134,10 @@ void CoLog::get( char categories[][20], char *item,
if ( EVEN(sts)) if ( EVEN(sts))
continue; continue;
if ( parts > 6) if ( parts > 7)
item_cb( ctx, time, line_array[4], line_array[5], line_array[6]); item_cb( ctx, time, line_array[4], line_array[5], line_array[6], line_array[7]);
else else
item_cb( ctx, time, line_array[4], line_array[5], 0); item_cb( ctx, time, line_array[4], line_array[5], line_array[6], 0);
} }
} }
......
...@@ -51,7 +51,7 @@ class CoLog ...@@ -51,7 +51,7 @@ class CoLog
void set_default() { m_default_log = this;} void set_default() { m_default_log = this;}
void log( const char *category, const char *str, const char *cmt, unsigned int opt = 0); void log( const char *category, const char *str, const char *cmt, unsigned int opt = 0);
void get( char categories[][20], char *item, void get( char categories[][20], char *item,
void item_cb( void *, pwr_tTime, char *, char *, char *), void *ctx); void item_cb( void *, pwr_tTime, char *, char *, char *, char *), void *ctx);
void push() { m_level++;} void push() { m_level++;}
void pull() { void pull() {
m_level--; m_level--;
...@@ -65,7 +65,7 @@ class CoLog ...@@ -65,7 +65,7 @@ class CoLog
if ( m_default_log) m_default_log->push();} if ( m_default_log) m_default_log->push();}
static void dpull() { static void dpull() {
if ( m_default_log) m_default_log->pull();} if ( m_default_log) m_default_log->pull();}
static void dget( char categories[][20], char *item, void item_cb( void *, pwr_tTime, char *, char *, char *), void *ctx) { static void dget( char categories[][20], char *item, void item_cb( void *, pwr_tTime, char *, char *, char *, char *), void *ctx) {
if ( m_default_log) m_default_log->get( categories, item, item_cb, ctx);} if ( m_default_log) m_default_log->get( categories, item, item_cb, ctx);}
}; };
......
...@@ -123,7 +123,10 @@ void CoLogWNavBrow::create_nodeclasses() ...@@ -123,7 +123,10 @@ void CoLogWNavBrow::create_nodeclasses()
brow_AddAnnot( nc_log, 13, 0.6, 2, brow_AddAnnot( nc_log, 13, 0.6, 2,
flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine, flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine,
0); 0);
brow_AddAnnot( nc_log, 30, 0.6, 3, brow_AddAnnot( nc_log, 18, 0.6, 3,
flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_log, 35, 0.6, 4,
flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine, flow_eDrawType_TextHelvetica, 2, flow_eAnnotType_OneLine,
1); 1);
brow_AddFrame( nc_log, 0, 0, 35, 0.83, flow_eDrawType_LineGray, -1, 1); brow_AddFrame( nc_log, 0, 0, 35, 0.83, flow_eDrawType_LineGray, -1, 1);
...@@ -377,8 +380,8 @@ int CoLogWNav::brow_cb( FlowCtx *ctx, flow_tEvent event) ...@@ -377,8 +380,8 @@ int CoLogWNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
} }
ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name, ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name,
pwr_tTime item_time, char *item_category, char *item_comment, pwr_tTime item_time, char *item_category, char *item_user,
brow_tNode dest, flow_eDest dest_code): char *item_comment, brow_tNode dest, flow_eDest dest_code):
logwnav(item_logwnav), time(item_time) logwnav(item_logwnav), time(item_time)
{ {
char time_str[40]; char time_str[40];
...@@ -387,6 +390,7 @@ ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name, ...@@ -387,6 +390,7 @@ ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name,
type = logwitem_eItemType_Log; type = logwitem_eItemType_Log;
strncpy( category, item_category, sizeof(category)); strncpy( category, item_category, sizeof(category));
strncpy( user, item_user, sizeof(user));
if ( item_comment) if ( item_comment)
strncpy( comment, item_comment, sizeof(comment)); strncpy( comment, item_comment, sizeof(comment));
else else
...@@ -402,6 +406,7 @@ ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name, ...@@ -402,6 +406,7 @@ ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name,
int annot = 0; int annot = 0;
brow_SetAnnotation( node, annot++, time_str, strlen(time_str)); brow_SetAnnotation( node, annot++, time_str, strlen(time_str));
brow_SetAnnotation( node, annot++, category, strlen(category)); brow_SetAnnotation( node, annot++, category, strlen(category));
brow_SetAnnotation( node, annot++, user, strlen(user));
if ( logwnav->show_item) if ( logwnav->show_item)
brow_SetAnnotation( node, annot++, item_name, strlen(item_name)); brow_SetAnnotation( node, annot++, item_name, strlen(item_name));
if ( item_comment) if ( item_comment)
...@@ -420,12 +425,12 @@ ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name, ...@@ -420,12 +425,12 @@ ItemLog::ItemLog( CoLogWNav *item_logwnav, const char *item_name,
} }
void CoLogWNav::item_cb( void *ctx, pwr_tTime time, char *category, char *item, void CoLogWNav::item_cb( void *ctx, pwr_tTime time, char *category, char *user, char *item,
char *comment) char *comment)
{ {
CoLogWNav *logwnav = (CoLogWNav *)ctx; CoLogWNav *logwnav = (CoLogWNav *)ctx;
new ItemLog( logwnav, item, time, category, comment, 0, flow_eDest_IntoLast); new ItemLog( logwnav, item, time, category, user, comment, 0, flow_eDest_IntoLast);
} }
void CoLogWNav::show( char categories[][20], char *item) void CoLogWNav::show( char categories[][20], char *item)
......
...@@ -80,20 +80,21 @@ class CoLogWNav { ...@@ -80,20 +80,21 @@ class CoLogWNav {
static int init_brow_cb( FlowCtx *fctx, void *client_data); static int init_brow_cb( FlowCtx *fctx, void *client_data);
static int brow_cb( FlowCtx *ctx, flow_tEvent event); static int brow_cb( FlowCtx *ctx, flow_tEvent event);
static void item_cb( void *ctx, pwr_tTime time, char *category, char *item, static void item_cb( void *ctx, pwr_tTime time, char *category, char *user, char *item,
char *comment); char *comment);
}; };
class ItemLog { class ItemLog {
public: public:
ItemLog( CoLogWNav *logwnav, const char *item_name, ItemLog( CoLogWNav *logwnav, const char *item_name,
pwr_tTime item_time, char *item_catogory, char *item_comment, pwr_tTime item_time, char *item_catogory, char *item_user, char *item_comment,
brow_tNode dest, flow_eDest dest_code); brow_tNode dest, flow_eDest dest_code);
logwitem_eItemType type; logwitem_eItemType type;
CoLogWNav *logwnav; CoLogWNav *logwnav;
brow_tNode node; brow_tNode node;
pwr_tTime time; pwr_tTime time;
char category[20]; char category[20];
char user[80];
char comment[256]; char comment[256];
virtual ~ItemLog() {} virtual ~ItemLog() {}
......
...@@ -144,3 +144,4 @@ ...@@ -144,3 +144,4 @@
091020 cs wb Expand/Compress in plc editor on GetATp, GetDTp, StoATp etc. 091020 cs wb Expand/Compress in plc editor on GetATp, GetDTp, StoATp etc.
091021 cs wb Crossreferences on channels added. 091021 cs wb Crossreferences on channels added.
091028 cs wb Syntax check works again with new check functions, and SyntaxCheck in configurator popup menu. 091028 cs wb Syntax check works again with new check functions, and SyntaxCheck in configurator popup menu.
091030 cs wb History log in wb.
\ No newline at end of file
...@@ -102,6 +102,12 @@ void wb_log::category_to_string( wlog_eCategory category, char *str) ...@@ -102,6 +102,12 @@ void wb_log::category_to_string( wlog_eCategory category, char *str)
case wlog_eCategory_GeExport: case wlog_eCategory_GeExport:
strcpy( str, "GeExport"); strcpy( str, "GeExport");
break; break;
case wlog_eCategory_UpdateClasses:
strcpy( str, "UpdateClasses");
break;
case wlog_eCategory_WbLoad:
strcpy( str, "WbLoad");
break;
default: default:
strcpy( str, ""); strcpy( str, "");
} }
...@@ -131,6 +137,10 @@ void wb_log::string_to_category( char *str, wlog_eCategory *category) ...@@ -131,6 +137,10 @@ void wb_log::string_to_category( char *str, wlog_eCategory *category)
*category = wlog_eCategory_CopyPackage; *category = wlog_eCategory_CopyPackage;
else if ( strcmp( str, "GeExport") == 0) else if ( strcmp( str, "GeExport") == 0)
*category = wlog_eCategory_GeExport; *category = wlog_eCategory_GeExport;
else if ( strcmp( str, "UpdateClasses") == 0)
*category = wlog_eCategory_UpdateClasses;
else if ( strcmp( str, "WbLoad") == 0)
*category = wlog_eCategory_WbLoad;
else else
*category = wlog_eCategory_; *category = wlog_eCategory_;
} }
......
...@@ -38,6 +38,8 @@ typedef enum { ...@@ -38,6 +38,8 @@ typedef enum {
wlog_eCategory_CreatePackage, wlog_eCategory_CreatePackage,
wlog_eCategory_CopyPackage, wlog_eCategory_CopyPackage,
wlog_eCategory_GeExport, wlog_eCategory_GeExport,
wlog_eCategory_UpdateClasses,
wlog_eCategory_WbLoad,
wlog_eCategory__, wlog_eCategory__,
} wlog_eCategory; } wlog_eCategory;
......
...@@ -1942,7 +1942,16 @@ void Wtt::activate_updateclasses() ...@@ -1942,7 +1942,16 @@ void Wtt::activate_updateclasses()
if ( !focused_wnav) if ( !focused_wnav)
set_focus_default(); set_focus_default();
set_clock_cursor(); set_clock_cursor();
unsigned int opt;
if ( focused_wnav->gbl.enable_comment)
opt = log_mOption_Comment;
else
opt = 0;
wb_log::log( (wb_session *)ldhses, wlog_eCategory_UpdateClasses, volid, opt);
focused_wnav->command( cmd); focused_wnav->command( cmd);
reset_cursor(); reset_cursor();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment