/**
 * @license
 * Copyright 2018 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.nanos.logger',
  name: 'LogMessage',

  documentation: 'Modelled log output.',

  implements: [
    'foam.nanos.auth.CreatedAware'
  ],

  tableColumns: [
    'created',
    'severity',
    'message'
  ],

  searchColumns: [
    'severity',
    'exception'
  ],

  properties: [
    {
      class: 'DateTime',
      name: 'created',
      visibility: 'RO'
    },
    {
      name: 'severity',
      class: 'Enum',
      of: 'foam.log.LogLevel',
      toJSON: function(value) { return value && value.label; },
      visibility: 'RO',
      tableCellFormatter: function(severity, obj, axiom) {
         this
          .start()
            .setAttribute('title', severity.label)
            .add(severity.label)
            .style({ color: severity.color })
          .end();
      },
    },
    {
      name: 'id',
      class: 'Long',
      storageTransient: 'true',
      hidden: 'true',
      visibility: 'RO'
    },
    {
      name: 'message',
      class: 'String',
      label: 'Log Message',
      visibility: foam.u2.Visibility.RO,
      view: { class: 'foam.u2.tag.TextArea', rows: 5, cols: 80 },
      visibility: 'RO'
    },
    // TODO: implement via an additional method on Logger logger.flag(x, y).log(message)
    // {
    //   name: 'flags',
    //   class: 'Map'
    // },
    {
      name: 'exception',
      class: 'Object',
      visibility: 'RO',
      view: { class: 'foam.u2.tag.TextArea', rows: 5, col: 80 }
    }
  ]
});

@@ -368,24 +368,39 @@
 hColumns: %5B%0A
+    'created',%0A
     'severit
@@ -399,24 +399,24 @@
 'severity',%0A
-
     'excepti
@@ -509,32 +509,55 @@
 visibility: 'RO'
+,%0A      tableWidth: 180
 %0A    %7D,%0A    %7B%0A  
@@ -696,34 +696,58 @@
 l; %7D,%0A      
-visibility
+createMode: 'RO',%0A      updateMode
 : 'RO',%0A    
@@ -987,24 +987,45 @@
 );%0A      %7D,%0A
+      tableWidth: 90%0A
     %7D,%0A    %7B
@@ -1120,32 +1120,8 @@
 rue'
-,%0A      visibility: 'RO'
 %0A   
@@ -1216,123 +1216,87 @@
   vi
-sibility: foam.u2.Visibility.RO,%0A      view: %7B class: 'foam.u2.tag.TextArea', rows: 5, cols: 80 %7D,%0A      visibility
+ew: %7B class: 'foam.u2.view.PreView' %7D,%0A      createMode: 'RO',%0A      updateMode
 : 'R
@@ -1517,32 +1517,8 @@
 t',%0A
-      visibility: 'RO',%0A
     
@@ -1547,41 +1547,71 @@
 .u2.
-tag.TextArea', rows: 5, col: 80 %7D
+view.PreView' %7D,%0A      createMode: 'RO',%0A      updateMode: 'RO'
 %0A   

Update view modes and table columns widths for LogMessage